Division of Candies
Easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
Two brothers, Misha and Pasha, bought some candies at the store. On their way home, the bag tore, and they ended up putting the candies in their pockets. Once home, they decided to split the candies equally. Misha had a candies, and Pasha had b candies. However, they chose a unique method to divide them. The brother with more candies would double the number of candies the other brother had, using his own candies to do so. They repeated this process until both had the same number of candies. Can they achieve an equal distribution, and if so, how many operations will it take?
Input
Two integers a and b, where (a + b < 2 \times 10^9).
Output
Print the number of operations required. If it's impossible to equalize the candies, print -1.
Examples
Input #1
Answer #1
Submissions 2K
Acceptance rate 14%