Rabbits
... and after a long sniffing, which is sometimes interrupted by sleep, rabbits begin to mate. Slowly and very tediously. That's why they are so rare. They bring offspring once every 10 years, and sometimes they bring them to places they can't even find themselves...
"Radio Day"
Snezana works as an accountant on a rabbit farm, where she counts rabbits daily. Her records start like this: 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, .... She noticed that starting from the third day, the number of rabbits each day is the sum of the rabbits from the two previous days.
Every night, Snezana places the rabbits into cages, with each cage holding exactly m
rabbits (no more, no less). She has an unlimited number of cages available. Her goal is to place as many rabbits as possible into these cages each night. Any rabbits that cannot be placed in cages will sleep in the aviary outside.
Snezana's boss has promised to pay her a salary whenever exactly a
rabbits are left to sleep in the aviary. Your task is to help Snezana determine the first day she will receive her salary.
Input
The first line contains two integers m
and a
(2 ≤ m ≤ 1000000
, 0 ≤ a < m
).
Output
Print the day number when Snezana will receive her first salary. If this never happens, print -1
.