def gcd(x,y): x,y=max(x,y),min(x,y) return x if y==0 else gcd(y, x%y) A,B=map(int,raw_input().strip().split(" ")) print gcd(A+B,A*B)