The rectangular hangars have sizes
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
In the first line is sizes of the hangars
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 ≤
N ≤ 30000.
A one number is the quantity of steps of
K, which Anfisa has to do.
5 4 25 38