m,n=input().split() m=int(m) n=int(n) x=m while x>1: if m%x==0 and n%x==0: break else: x=x-1 print(x)