# Magic machine

Very easy

Execution time limit is 1 second

Runtime memory usage limit is 128 megabytes

Ibrahim has a black magic machine. It has three buttons and a display. Display can show no more than a four-digit number. Each of the buttons changes the number in some way: the first is multiplies it by 3, the second adds to it the sum of digits, and the third button subtracts 2. If the number becomes negative or greater than 9999, the machine breaks.

Ibrahim can press the buttons in any order. He wondered how to get on the display the number b after a certain sequence of clicks, if currently the machine shows a. Help him to find the minimum number of keystrokes.

## Input

Two integers a and b (1 ≤ a, b ≤ 9999).

## Output

Print the minimal number of operations to get b from a.

## Examples

Input #1

Answer #1

Input #2

Answer #2

Input #3

Answer #3

Submissions 4K

Acceptance rate 38%