def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y)


if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result)) def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y) calc_gcd """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """ if y == 0:
        return x
    else:
        return calc_gcd(y, x % y) y == 0 y 0 return x x return calc_gcd(y, x % y) calc_gcd(y, x % y) calc_gcd y x % y x y x x y y if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result)) __name__ == '__main__' __name__ '__main__' int(x) for x in input().split(' ') for x in input().split(' ') x input().split(' ') ().split () input split ' ' for x in input().split(' ') int(x) int x data = [int(x) for x in input().split(' ')] data [int(x) for x in input().split(' ')] result = calc_gcd(data[0], data[1]) result calc_gcd(data[0], data[1]) calc_gcd data[0] data 0 data[1] data 1 print('{0}'.format(result)) print '{0}'.format(result) '{0}'.format '{0}' format result result = calc_gcd(data[0], data[1]) calc_gcd(data[0], data[1]) result def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y) def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y) calc_gcd data = [int(x) for x in input().split(' ')] [int(x) for x in input().split(' ')] data
def calc_gcd(x, y):
    """
    math.gcd()????????¨??§????????????python3.5??\??????AOJ???python?????????????????????3.4????????§?????¨??§?????????
    """
    if y == 0:
        return x
    else:
        return calc_gcd(y, x % y)


if __name__ == '__main__':
    data = [int(x) for x in input().split(' ')]
    result = calc_gcd(data[0], data[1])
    print('{0}'.format(result))