atcoder#ABC188F. [ABC188F] +1-1x2

[ABC188F] +1-1x2

Score : 600600 points

Problem Statement

Takahashi has written an integer XX 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 11;
  • decrease the value written on the blackboard by 11;
  • multiply the value written on the blackboard by 22.

Find the minimum number of operations required to have YY written on the blackboard.

Constraints

  • 1X10181 \le X \le 10^{18}
  • 1Y10181 \le Y \le 10^{18}
  • XX and YY are integers.

Input

Input is given from Standard Input in the following format:

XX YY

Output

Print the answer.

3 9
3

Initially, 33 is written on the blackboard. The following three operations can make it 99:

  • increase the value by 11, which results in 44;
  • multiply the value by 22, which results in 88;
  • increase the value by 11, which results in 99.
7 11
3

The following procedure can make the value on the blackboard 1111:

  • decrease the value by 11, which results in 66;
  • multiply the value by 22, which results in 1212;
  • decrease the value by 11, which results in 1111.
1000000000000000000 1000000000000000000
0

If the value initially written on the blackboard equals YY, print 00.