Competitions

# Азербайджан - подготовка. Март 10

# Cake from Tolya

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

Print the minimum number of cake pieces.

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