cho.sh
Notes
Loading...

Sick Knight

Time limit

2s

Memory limit

128 MB

Problem

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.

  1. 2 cells up and 1 cell right
  2. 1 cell up and 2 cells right
  3. 1 cell down and 2 cells right
  4. 2 cells down and 1 cell right

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.

Input

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.

Output

Print the maximum number of cells the knight can visit during its trip.