m,n = map(int,input().split()) if m<n: m,n = n,m t = n while True: if m%t==0 and n%t==0: break t -=1 print(t)