def gcd(a,b):
    x,y = (a,b) if a>b else (b,a)
    if x % y == 0:
        return y
    else:
        return gcd(y, x % y)

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

a,b = map(int, input().split())
print(gcd(a,b))