def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y)

if __name__ == '__main__':
    x, y = [int(x) for x in input().split()]
    print(greatest_common_divisor(x, y)) def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y) greatest_common_divisor if x < y:
        x, y = y, x

     x < y x y x, y = y, x x y y x if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y) y == 0 y 0 return x x return greatest_common_divisor(y, x % y) greatest_common_divisor(y, x % y) greatest_common_divisor y x % y x y x x y y if __name__ == '__main__':
    x, y = [int(x) for x in input().split()]
    print(greatest_common_divisor(x, y)) __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 x, y = [int(x) for x in input().split()] x [int(x) for x in input().split()] y print(greatest_common_divisor(x, y)) print greatest_common_divisor(x, y) greatest_common_divisor x y y = [int(x) for x in input().split()] [int(x) for x in input().split()] y def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y) def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y) greatest_common_divisor x, y = [int(x) for x in input().split()] [int(x) for x in input().split()] x
def greatest_common_divisor(x, y):
    if x < y:
        x, y = y, x

    if y == 0:
        return x
    else:
        return greatest_common_divisor(y, x % y)

if __name__ == '__main__':
    x, y = [int(x) for x in input().split()]
    print(greatest_common_divisor(x, y))