KNIGHT
You are given a chessboard with dimensions , in the bottom-left corner of which there is a knight. In chess, the knight moves in an "" shape, which means two squares in one direction (horizontally or vertically) and one square in the perpendicular direction. The task is to find the minimum number of moves the knight must make to reach the top-right corner of the chessboard.
Input
The first line of the input contains two integers and , separated by a single space: the dimensions of the chessboard.
Output
The output should consist of a single line containing exactly one integer: the minimum number of moves required to bring the knight from the bottom-left to the top-right corner of the chessboard.
Constraints
.
Execution time limit: 1 sec.
Memory limit: 128 MB.
Examples of Input - Output
1st
STDIN (knight.in)
5 6
STDOUT (knight.out)
3
2nd
STDIN (knight.in)
8 8
STDOUT (knight.out)
6
Comments