M, N = map(int, input().split()) cnt = 0 while M: if N > M: N, M = M, N cnt += 1 else: q, mod = divmod(M, N) M = mod cnt += q print(cnt-1)