Time limit
2s
Memory limit
128 MB
A sick knight stands on the bottom-left cell of an N x M chessboard. Unlike an ordinary knight, it can move only in the following four ways.
The knight wants to travel while maximizing the number of cells it visits. However, if it makes at least 4 moves, it must use each of the four move types at least once. If it makes at most 3 moves, there is no additional restriction on the move types.
Given N and M, find the maximum number of cells the knight can visit.
The first line contains the chessboard height N and width M. Both N and M are positive integers not greater than 2,000,000,000.
Print the maximum number of cells the knight can visit during its trip.