# coding: utf-8

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

def main():
    a, b = map(int, raw_input().split())
    print gcd(a, b)

if __name__ == '__main__':
    main() def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a gcd if a < b:
        a, b = b, a
     a < b a b a, b = b, a a b b a while b:
        a, b = b, a % b
     b a, b = b, a % b a b b a % b a b return a a a a b b def main():
    a, b = map(int, raw_input().split())
    print gcd(a, b) main a, b = map(int, raw_input().split()) a map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split b print gcd(a, b) gcd a b if __name__ == '__main__':
    main() __name__ == '__main__' __name__ '__main__' main() main def main():
    a, b = map(int, raw_input().split())
    print gcd(a, b) def main():
    a, b = map(int, raw_input().split())
    print gcd(a, b) main def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a % b
    return a gcd
# coding: utf-8

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

def main():
    a, b = map(int, raw_input().split())
    print gcd(a, b)

if __name__ == '__main__':
    main()