A. Survival and Chocolate
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

Tom and Jerry found a rectangular chocolate bar of size $$$n \times m$$$, consisting of square pieces $$$1 \times 1$$$. Tom allowed Jerry to perform any number (possibly zero) of the following actions:

  1. First, cut the chocolate bar into two rectangles with integer sides along the piece boundaries, so that these two rectangles have a pair of sides of equal length.
  2. Then, glue the rectangles back together, aligning the sides of equal length, and resulting in a rectangular chocolate bar again. If the rectangles have multiple pairs of sides of equal length, Jerry can choose any pair.

Tom wants Jerry to obtain a chocolate bar with the maximum possible perimeter. If Jerry can solve this task, Tom will give him the chocolate bar, otherwise he will eat both Jerry and the chocolate bar.

Help Jerry determine the maximum possible perimeter the chocolate bar can have after several actions.

Input

The first line contains two integers $$$n$$$ and $$$m$$$ separated by a space - the dimensions of the chocolate bar ($$$1 \le n, m \le 10^9$$$).

Output

Output a single integer - the maximum possible perimeter of the chocolate bar.

Scoring

Points for each subtask are awarded only if all tests for that subtask and the required subtasks are passed.

SubtaskPointsConstraints Required subtasks Test information
130$$$n \le 100$$$first error
230 One side of the chocolate bar is a power of two first error
340No additional constraints1, 2first error
Examples
Input
10 4
Output
82
Input
7 10
Output
38
Note

In the first example, Jerry can act as follows:

  1. First, cut the $$$10 \times 4$$$ chocolate bar into two rectangles $$$10 \times 2$$$ and $$$10 \times 2$$$.
  2. Glue the rectangles together to form a $$$20 \times 2$$$ chocolate bar.
  3. Cut the $$$20 \times 2$$$ chocolate bar into two rectangles $$$20 \times 1$$$ and $$$20 \times 1$$$.
  4. Glue the rectangles together to form a $$$40 \times 1$$$ chocolate bar.

The final perimeter will be $$$40 \cdot 2 + 1 \cdot 2 = 82$$$.