def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a


if __name__ == '__main__':
    a, b = [int(n) for n in input().split()]
    print(gcd(a, b))

6d3b753c9d095b5bd05b083a80de3c86b6829aaa
<mask token>

def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a


<mask token>

def gcd(a, b):
    while b != 0:
        r = a % b
        a = b
        b = r
    return a


if __name__ == '__main__':
    a, b = [int(n) for n in input().split()]
    print(gcd(a, b))
