Snail 2

Time limit2sMemory limit128 MB

Problem

Draw a line on an M-row, N-column grid. Start from the upper-left cell and move to the right first.

The diagram below shows the path for M=5 and N=3. If the next cell would be outside the grid or has already been visited by the line, turn clockwise and continue.

end

Diagonal arrows indicate cells where the direction changes. Determine how many times the line changes direction before every cell of the grid is filled.

Input

The first line contains M and N separated by a space.

  • 2 ≤ M, N ≤ 100

Output

Print the number of direction changes made before every cell of the grid is filled.