#abc297d. [abc297_d]Count Subtractions

[abc297_d]Count Subtractions

Problem Statement

You are given positive integers AA and BB.

You will repeat the following operation until A=BA=B:

  • compare AA and BB to perform one of the following two:
    • if A>BA > B, replace AA with ABA-B;
    • if A<BA < B, replace BB with BAB-A.

How many times will you repeat it until A=BA=B? It is guaranteed that a finite repetition makes A=BA=B.

Constraints

  • 1leA,Ble10181 \\le A,B \\le 10^{18}
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

AA BB

Output

Print the answer.


Sample Input 1

3 8

Sample Output 1

4

Initially, A=3A=3 and B=8B=8. You repeat the operation as follows:

  • A<BA<B, so replace BB with BA=5B-A=5, making A=3A=3 and B=5B=5.
  • A<BA<B, so replace BB with BA=2B-A=2, making A=3A=3 and B=2B=2.
  • A>BA>B, so replace AA with AB=1A-B=1, making A=1A=1 and B=2B=2.
  • A<BA<B, so replace BB with BA=1B-A=1, making A=1A=1 and B=1B=1.

Thus, you repeat it four times.


Sample Input 2

1234567890 1234567890

Sample Output 2

0

Note that the input may not fit into a 32-bit integer type.


Sample Input 3

1597 987

Sample Output 3

15