def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

a, b = map(int, input().split())
print(gcd(a, b)) def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y) gcd if x < y:
        return gcd(y, x)
     x < y x y return gcd(y, x) gcd(y, x) gcd y x 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 x x y y 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 a, b = map(int, input().split()) map(int, input().split()) a def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y) def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y) gcd b = map(int, input().split()) map(int, input().split()) b
def gcd(x, y):
    if x < y:
        return gcd(y, x)
    if x%y == 0:
        return y
    else:
        return gcd(y, x%y)

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