Anfisa’s Holiday
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?
Specifications
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.
Problem information
Time Limit: 1 secondsMemory Limit: 64 MB
Balls for the passed test: 10
Complexity: 39% 31/51
Example
Example input5 4 25 38 |
Example output5 |
| ← The Cheese for Anfisa | Problems | Murzyk → |
