
def gcd(a, b):
    if b>a:
        b, a = a, b

    d = 1
    while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

    return b


a, b = map(int, input().split())
print(gcd(a, b)) def gcd(a, b):
    if b>a:
        b, a = a, b

    d = 1
    while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

    return b gcd if b>a:
        b, a = a, b

     b>a b a b, a = a, b b a a b d = 1 d 1 while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

     True d = a % b d a % b a b if d == 0:
            break
         d == 0 d 0 break a, b = b, d a b b d return b b 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 def gcd(a, b):
    if b>a:
        b, a = a, b

    d = 1
    while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

    return b def gcd(a, b):
    if b>a:
        b, a = a, b

    d = 1
    while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

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

def gcd(a, b):
    if b>a:
        b, a = a, b

    d = 1
    while True:
        d = a % b
        if d == 0:
            break
        a, b = b, d

    return b


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