def gcd(a, b):
    # ?????§??¬?´???°
    while b > 0:
        a, b = b, a % b
    return a
a, b = map(int, input().split())
print(gcd(a, b)) def gcd(a, b):
    # ?????§??¬?´???°
    while b > 0:
        a, b = b, a % b
    return a gcd while b > 0:
        a, b = b, a % b
     b > 0 b 0 a, b = b, a % b a b b a % b a b return a a 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 def gcd(a, b):
    # ?????§??¬?´???°
    while b > 0:
        a, b = b, a % b
    return a def gcd(a, b):
    # ?????§??¬?´???°
    while b > 0:
        a, b = b, a % b
    return a gcd 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):
    # ?????§??¬?´???°
    while b > 0:
        a, b = b, a % b
    return a
a, b = map(int, input().split())
print(gcd(a, b))