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?
Two integers m and n (1 ≤ m, n ≤ 30000).
The minimum number of cake pieces.
Time limit 1 seconds
Memory limit 122.17 MiB
2 3
4
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