Transform

Time Limit: 4000/2000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others)

Problem Description

One can transform \(x\) into \(x + d\) if \(d\) is divisor of \(x\). Find out the minimum number of steps to transform \(a\) into \(b\).

Input

Two integers \(a\) and \(b\).

(\(1 \leq a, b \leq 10^5\))

Output

The only integer denotes the minimum number of steps. Print \(-1\) if impossible.

Sample Input

1 6

Sample Output

3

Hint

\(1 \to 2 \to 4 \to 6\) or \(1 \to 2 \to 3 \to 6\).

Source

ftiasch

Manager

Information
Solved Number159
Submit Number606
Problem Tags
dfs and similar
dp
No tag edit access
温馨提示:AC后可以编辑标签哦. ^-^
Login
LoginCancel