def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a)


def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b))


if __name__ == '__main__':
    run()
 def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a) gcd """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """ if a > b:
        a, b = b, a

     a > b a b a, b = b, a a b b a if a == 0:
        return b

     a == 0 a 0 return b b return gcd(b % a, a) gcd(b % a, a) gcd b % a b a a a a b b def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b)) run 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 a, b = [int(i) for i in input().split()] a [int(i) for i in input().split()] b print(gcd(a, b)) print gcd(a, b) gcd a b if __name__ == '__main__':
    run() __name__ == '__main__' __name__ '__main__' run() run def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a) def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a) gcd def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b)) def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b)) run
def gcd(a, b):
    """calculate the greatest common divisor of a, b

    >>> gcd(54, 20)
    2
    >>> gcd(147, 105)
    21
    >>> gcd(100000002, 39273000)
    114
    """
    if a > b:
        a, b = b, a

    if a == 0:
        return b

    return gcd(b % a, a)


def run():
    a, b = [int(i) for i in input().split()]
    print(gcd(a, b))


if __name__ == '__main__':
    run()

