Assume that there is a number
a. In every conversion of that number, the number can either convert itself to its value plus the value of one of its digits, or convert itself to its value minus the value of one of its digits.
In this situation, find the minimum number of conversions one has to make in order to get to the number
b. If b cannot be reached, output
Input one line containing the integers a and b (where 1 <= a, and b <= 10^6).
Output a line containing one integer, which represents the minimum amount that one has to convert the number.
Example input and output (s)
Input: 1 10 Output: 5
1 -> 1+1=2 -> 2+2=4 -> 4+4=8 -> 8+8=16 -> 16-6=10 => 10
The shortest program wins, as this is a code golf question.