2020 Цикл Интернет-олимпиад для школьников, первая командная олимпиада, 18 октября
Important scientific number
Pin was assembling his very important new invention, but at some point he discovered that he had made a mistake in one of the formulas and could have assembled the corresponding part incorrectly.
After carefully looking at the detail and correcting the formula, Pin noted that now the part contains two gears with a and b teeth, respectively, and it will work correctly with gears of sizes a + x and b + x respectively, where x is a non-negative integer such that a + x is divisible by b and b + x is divisible by a.
Pin is very tired, so he asks you to help him find such a non-negative x that satisfies the given conditions. Because Pin doesn't like big gears, the minimum of all possible x values should be chosen.
Input data
One line contains two numbers a and b (1 ≤ a, b ≤ 10^9
) - the sizes of the gears in the detail.
Output data
Print one non-negative integer x - the minimum number of teeth missing in the gears for the invention to work correctly.
Examples
8 1
7
3 4
5
123 123
0