cswork / OAOpen practice workspace

XperiOA #2

Make Numbers Equal

EasyJudge-ready

Topics (AI-labelled)Bits & Math

There are two positive integers A and B, and you need to make A and B equal through some operations. In each operation: if A is greater than B, then A=A−B; if B is greater than A, then B=B−A. Each operation costs 1. Find the total cost to make A equal to B.

Input

One line with two space-separated integers A and B. 1≤A,B≤10^18.

Output

Output one integer, the total cost.

Example 1

Input:

7 9

Output:

5

Example 2

Input:

4 4

Output:

0

Example 3

Input:

12 3

Output:

3

Example notes

Example 1: A=7, B=9. B=9−7=2, A=7−2=5, A=5−2=3, A=3−2=1, B=2−1=1, for 5 operations in total. Example 2: A and B are equal from the start, so the cost is 0. Example 3: 12→9→6→3, for 3 operations in total.

Editorial

Loading solution…