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)