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

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

x, y = map(int, input().split())
print(greatest_common_division(x, y))
 def greatest_common_division(x, y):
    if x < y:
        x, y = y, x

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

     x < y x y x, y = y, x x y y x if y == 0 or x == y:
        return x
    else:
        return greatest_common_division(y, x % y) y == 0 or x == y y == 0 y 0 x == y x y return x x return greatest_common_division(y, x % y) greatest_common_division(y, x % y) greatest_common_division y x % y x y x x y y x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y print(greatest_common_division(x, y)) print greatest_common_division(x, y) greatest_common_division x y x, y = map(int, input().split()) map(int, input().split()) x y = map(int, input().split()) map(int, input().split()) y def greatest_common_division(x, y):
    if x < y:
        x, y = y, x

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

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

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

x, y = map(int, input().split())
print(greatest_common_division(x, y))

