def gcd(a,b): if a>b: m=a t=b else: m=b t=a r=m%t while r!=0: m=t t=r r=m%t return t A,B=(int(i) for i in input (). split ()) print (gcd(A,B))