#Greatest Common Diveser
def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b

x, y = map(int, input().split())
print(gcd(x, y)) def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b gcd while a > 0:
        if a < b: a, b = b, a
        a = a % b
     a > 0 a 0 if a < b: a, b = b, a
         a < b a b a = a % b a a % b a b return b b a a b b x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(gcd(x, y)) print gcd(x, y) gcd x y x, y = map(int, input().split()) map(int, input().split()) x y = map(int, input().split()) map(int, input().split()) y def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b gcd
#Greatest Common Diveser
def gcd(a, b):
    while a > 0:
        if a < b: a, b = b, a
        a = a % b
    return b

x, y = map(int, input().split())
print(gcd(x, y))