Олимпиадный тренинг

Задача 30716. Prizes


Задача

Темы:
The organizers of the All-Russian Team Programming Olympiad for schoolchildren always treat all stages of the competition responsibly. T-shirts for the participants of the Olympiad were recently delivered to the organizers. They were stacked in a box, which is a cube with a side of one meter. The box was placed in the corner of a rectangular room measuring m × n meters. So that no one accidentally took the box, the word "VKOSHP" was written on its upper edge with red paint.

Today, the organizers suddenly needed to move this box to the opposite corner of the room. But, unfortunately, the box turned out to be so heavy that no one could move it. It turned out that everything that can be done with the — roll it over the edge of the bottom face. In this case, the corresponding edge remains in the same place, and another face adjacent to this edge becomes the bottom one.

The organizers of the Olympiad faced the following task. They need to roll the box from the corner of the room in which it stands to the opposite corner. At the same time, even rolling the box is very difficult, so the organizers decided to minimize the number of rolls of the box.

But when they were about to start transporting, another problem emerged. The red inscription "VKOSHP" every time it touches the floor, it leaves marks on it. Therefore, among all transportation options that minimize the number of rolls, the organizers decided to choose the one in which the inscription "VKOSHP" will appear on the bottom face of the cube the minimum number of times.

Help the organizers — count how many times the inscription "VKOSHP" touches the floor while optimally rolling the T-shirt cube.

Input data format
The first line contains two integers n and m (1 ≤ n, m ≤ 109 ) — room dimensions in meters.

Output data format
Print one number — how many times the inscription "VKOSHP" will be on the bottom edge when the box is optimally moved.

Enter Output
1 2 0
3 3 1


Explanation

In the first example, one roll is needed, the inscription, which was originally on the top face, will be on the side face, but will not touch the floor.
In the second example, four rolls are needed. In any case, at least once the inscription "VKOSHP" touches the floor. One way to make rolling so that it happens once, the next. First, roll the cube twice in the same direction (it will be in the next corner of the room). Now the inscription "VKOSHP" is on the bottom edge and touches the floor. Then roll the cube two more times in the perpendicular direction. The cube is now in the correct position.