eolymp
bolt
Try our new interface for solving problems
Problems

The Parquet of the Triangles

The Parquet of the Triangles

\includegraphics{https://static.e-olymp.com/content/3d/3d41f4177ca08c38fc9a59aebd76660a97b0f0fa.gif} We laid by three-cornered tiles the rectangular room with sides \textbf{M} to \textbf{N} (at first for hori-zontal lines, and then for vertical lines) and we numbered it as shown on the picture. It is possible to move from one parquet to another through a general side only for one step. Find the least quantity of steps, which necessary for transferring from parquet \textbf{A} to parquet \textbf{B}. \InputFile In the input file in the first line through the gap is set to \textbf{M}, \textbf{N }(\textbf{1} ≤ \textbf{M}, \textbf{N} ≤ \textbf{100}), and the second - \textbf{A}, \textbf{B}. \textbf{Output } The desired number of steps.
Time limit 1 second
Memory limit 64 MiB
Input example #1
5 4
25 38
Output example #1
5
Author Анатолий Присяжнюк