410580: GYM104059 A Alternative Architecture

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

A. Alternative Architecturetime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

In his free time, Thomas greatly enjoys working on the extensive Lego project that he has built in his attic, adding house after house to his miniature city. However, he has become a bit bored with the completely rectangular layout that is enforced by the little studs of the huge base plate that his city is built on.

After an exchange with some other Lego creators he came across a technique that will allow him to place his buildings at different angles. Each building rests on a rectangular ground plate, to the underside of which he attaches four round $$$1\times 1$$$-plates in the corners. These $$$1\times 1$$$-plates are then placed on four studs of the base plate, like in Figure 1 above.

If the ground plate of the building is $$$a\times b$$$ studs, what is the number of orientations it can be placed in using this technique, so that all the corner plates exactly fit on studs of the base plate?

Input

The input consists of:

  • One line with two integers $$$a$$$ and $$$b$$$ ($$$2 \le a,b \le 10^6$$$), the dimensions of the ground plate the building is resting on.
Output

Output one integer, the number of different orientations the ground plate can be placed in.

ExamplesInput
6 11
Output
6
Input
26 26
Output
5
Input
123 456
Output
2
Input
3 3
Output
1

加入题单

算法标签: