def gcd(a, b):
    while b != 0:
        # gcd(a, b) == gcd(b, a%b)
        rem = a % b
        a = b
        b = rem
    return a

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

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