Anfisa’s Holiday
Medium
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
The rectangular hangars have sizes M
and N
(at first for horizontal lines, and then for vertical lines). It was cluttering up by three-cornered tiles. These tiles were numbered as shown on the picture.
Anfisa can move from one tiles to other only through a general side for a one step. What least quantity of steps has to do Anfisa to the piece of cheese which placed on tile with number B
if she is being on the tile with number A
?
Input
In the first line is sizes of the hangars M
and N
. In the second line is number of tile A
in which Anfisa is being and number of the tile B
with the piece of cheese. 1 ≤ M
, N
≤ 30000.
Output
A one number is the quantity of steps of K
, which Anfisa has to do.
Examples
Input #1
Answer #1
Submissions 775
Acceptance rate 16%