URI Online Judge | 1897

Smart Game

By Thalyson Nepomuceno, Universidade Estadual do Ceará BR Brazil

Timelimit: 2

While Bino rested, he invented a smart game. Given the number N and the number M, Bino want to know how many operations are necessary to convert N into M.

Six operations are allowed:

Input

The input consists of two integers N ( 0 ≤ N ≤ 10000) and M ( 0 ≤ M ≤ 10000).

Output

The output is the minimum number of operations to convert N into M.

Input Samples Output Samples

10 15

2

45 15

1

84 63

3