m,n=gets.split.map{|e| e.to_i} d=m.gcd(n) m/=d n/=d ans=0 while m+n>2 if m