Page not loading? Try clicking here.
Placeholder

#6303

The process of X becoming greater than or equal to N 1s 1024MB

Problems

Given integers X, N as input, write a program that outputs how many times the following operations must be performed on X for it to become greater than or equal to N.

The value of X changes according to the following rules.

For the changing X, assume that the remainder when X is divided by 3 is r.

  • If r=0, add 1 to X.

  • If r=1, multiply X by 2.

  • If r=2, multiply X by 3.


Input

Input is provided in the following format.

X

N

  • 1 \le X < N \le 100\ 000

  • X, N are integers.


Output

Print the minimum number of operations required for X to become at least N.


Example #1

2
40
4

Example #2

3
4
1

Example #3

20
62
3

Example #4

1
100000
19


Source

JOI 2024 예선

You must sign in to write code.