A,B=map(int,input().split()) A,B=min(A,B),max(A,B) if B%A==0: print(A) else: def gcd(a,b): a,b=max(a,b),min(a,b) if a%b==0: return b while b%a!=0: return gcd(b,a%b) print(gcd(gcd(A+B,A),gcd(A+B,B)))