# GCD
def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


x, y = [int(i) for i in input().split()]

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d) def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d gcd if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

     x % y > 0 x % y x y 0 r = x % y r x % y x y d = gcd(y, r) d gcd(y, r) gcd y r d = y d y return d d x x y y int(i) for i in input().split() for i in input().split() i input().split() ().split () input split for i in input().split() int(i) int i x, y = [int(i) for i in input().split()] x [int(i) for i in input().split()] y if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit() x < y x y buff = x buff x x = y x y y = buff y buff elif x == y:
    print(x)
    exit() x == y x y print(x) print x exit() exit d = gcd(x, y) d gcd(x, y) gcd x y print(d) print d d = gcd(x, y) gcd(x, y) d y = buff buff y x, y = [int(i) for i in input().split()] [int(i) for i in input().split()] x def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d gcd y = [int(i) for i in input().split()] [int(i) for i in input().split()] y buff = x x buff x = y y x
# GCD
def gcd(x, y):
    if x % y > 0:
        r = x % y
        d = gcd(y, r)
    else:
        d = y

    return d


x, y = [int(i) for i in input().split()]

if x < y:
    buff = x
    x = y
    y = buff
elif x == y:
    print(x)
    exit()

d = gcd(x, y)

print(d)