A,B=map(int,input().split()) a,b=A+B,A*B while a:b,a=a,b%a print(b)