Олимпиадный тренинг

Задача 38469. ducks


Задача

Темы: Целые числа
As you know, when developing and debugging programs, toy yellow ducks can be of great help (see the article "The Duck Method" on Wikipedia), so Denis has collected a large collection of yellow ducks. The collection is already so big that Denis decided to place the ducks on the cabinet shelves. At first he began to put A ducks on each shelf, but one duck turned out to be superfluous. Then he began to put the ducks on the shelves again, placing B ducks on each shelf, but in this case, one duck was not enough for him to have exactly B ducks on each shelf. Determine the minimum number of ducks that could be in Denis's collection.
The program receives as input two positive integers A and B, 2 ≤ A≤ 2×109, 2≤ B≤ 2×109 – the number of ducks when placed on the shelf in the first and second cases.
The program should output a single number – the minimum possible number of ducks in Denis's collection. It is guaranteed that the answer exists and does not exceed 2×109.
Examples
# Input Output Explanation
1 5
3
11 11 = 5 x times; 2+1
11=3.times. 4 ? 1