import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines x,y = map(int,read().split()) answer = 0 while x != y: if x < y: x,y = y,x answer += 1 q,r = divmod(x,y) if r: x,y = r,y answer += q else: x = y; answer += q - 1 print(answer)