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

Задача 38356. broken calculator


The calculator has two memory cells: the contents of the first one are always displayed on the display, the second is a buffer. At the initial moment of time, the calculator displays an integer X, and the buffer contains the number 0. The calculator has only two keys: "+" and «=». By clicking on the "+" the number that is currently displayed on the scoreboard is copied to the buffer. When you click on «=» the number from the buffer is added to the number displayed on the scoreboard and the result is displayed on the scoreboard, the number in the buffer does not change.

It is required for the least number of keystrokes on the calculator to ensure that the number Y is displayed on the scoreboard.

Input
The input file contains two integers X and Y. Each of these numbers does not exceed 109 in absolute value.

Imprint
In the first line of the output file print a single number — the number of keystrokes required to obtain the number Y. If it is impossible to obtain the number Y from the number X using the specified operations, output a single number –1 to the output file.
Examples
# Input Output
1 -1 -8 6
2 2 16 6
3 0 0 0