e-olymp
favorite We need a little bit of your help to keep things running, click on this banner to learn more
Problems

Anfisa’s Holiday

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.

prb53

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.

Time limit 1 second
Memory limit 64 MiB
Input example #1
5 4
25 38
Output example #1
5