m,n=gets.split.map(&:to_i) def go(m, n) return 0 if n==0 return go(n, m)+1 if m