Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Cake from Tolya

![1257493652.gif](1257493652.gif]

On his birthday Tolya wants to regale his friends with cake. It is known that at the birthday party can be either n, or m people, including Tolya. What is the minimum number of parts the cake must be cut (not necessarily all equal), so that for either n or m guests, all can eat the cake evenly?

Input

Two integers m and n (1 ≤ m, n ≤ 30000).

Output

The minimum number of cake pieces.

Time limit 1 seconds

Memory limit 122.17 MiB

Input example #1

2 3

Output example #1

4

Example description:

The cake should be cut into pieces 1/3, 1/3, 1/6 and 1/6. Then, for 2 holiday parties each eat 1/3 + 1/6, and at 3-one eats, respectively: 1/3, 1/3, 1/6 + 1/6 = 1/3