a,b = map(int,input().split()) def gcd(x,y): while True: r = x % y x = y y = r if r == 0: return x print(gcd(a,b))