# your code goes here #magic M,N=(int(i) for i in input().split()) c=0 if N>M: t=M M=N N=t c+=1 while N>0: t=N c+=M//N+ 1 N=M%N M=t # print (c) c-=2 print(c)