#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

    print(gcd(X,Y))

if __name__ == "__main__": main() def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b) gcd if b == 0: return a
     b == 0 b 0 return gcd(b, a % b) gcd(b, a % b) gcd b a % b a b a a b b 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 if __name__ == "__main__": main() __name__ == "__main__" __name__ "__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 b == 0: return a
    return gcd(b, a % b) def gcd(a, b):
    if b == 0: return a
    return gcd(b, a % b) gcd
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

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

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

    print(gcd(X,Y))

if __name__ == "__main__": main()