atcoder#ABC188F. [ABC188F] +1-1x2
[ABC188F] +1-1x2
Score : points
Problem Statement
Takahashi has written an integer on a blackboard. He can do the following three kinds of operations any number of times in any order:
- increase the value written on the blackboard by ;
- decrease the value written on the blackboard by ;
- multiply the value written on the blackboard by .
Find the minimum number of operations required to have written on the blackboard.
Constraints
- and are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 9
3
Initially, is written on the blackboard. The following three operations can make it :
- increase the value by , which results in ;
- multiply the value by , which results in ;
- increase the value by , which results in .
7 11
3
The following procedure can make the value on the blackboard :
- decrease the value by , which results in ;
- multiply the value by , which results in ;
- decrease the value by , which results in .
1000000000000000000 1000000000000000000
0
If the value initially written on the blackboard equals , print .