N,M = map(int,input().split()) ans = 0 while N != M: if N < M: M,N = N,M ans += 1 elif N % M == 0: ans += N//M -1 break else: ans += N//M N %= M print(ans)