def main():
    X, Y = map(int, input().split())

    print(gcd(X, Y))

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b)

main() def main():
    X, Y = map(int, input().split())

    print(gcd(X, Y)) main 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 def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b) gcd if a < b:
        a, b = b, a
     a < b a b a, b = b, a a b b a r = a % b r a % b a b if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b) r == 0 r 0 return b b a = b a b b = r b r return gcd(a, b) gcd(a, b) gcd a b a a b b main() main def main():
    X, Y = map(int, input().split())

    print(gcd(X, Y)) def main():
    X, Y = map(int, input().split())

    print(gcd(X, Y)) main def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b) def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b) gcd
def main():
    X, Y = map(int, input().split())

    print(gcd(X, Y))

def gcd(a, b):
    if a < b:
        a, b = b, a
    r = a % b
    if r == 0:
        return b
    else:
        a = b
        b = r
        return gcd(a, b)

main()