def euclideanAlgorithm(x, y):
    if y == 0: return x
    return euclideanAlgorithm(y, x%y)

# MAIN
x, y = map(int, raw_input().split())
print euclideanAlgorithm(x, y) def euclideanAlgorithm(x, y):
    if y == 0: return x
    return euclideanAlgorithm(y, x%y)

# MAIN euclideanAlgorithm if y == 0: return x
     y == 0 y 0 return euclideanAlgorithm(y, x%y) euclideanAlgorithm(y, x%y) euclideanAlgorithm y x%y x y x x y y x, y = map(int, raw_input().split()) x map(int, raw_input().split()) map int raw_input().split() ().split () raw_input split y print euclideanAlgorithm(x, y) euclideanAlgorithm x y def euclideanAlgorithm(x, y):
    if y == 0: return x
    return euclideanAlgorithm(y, x%y)

# MAIN def euclideanAlgorithm(x, y):
    if y == 0: return x
    return euclideanAlgorithm(y, x%y)

# MAIN euclideanAlgorithm y = map(int, raw_input().split()) map(int, raw_input().split()) y x, y = map(int, raw_input().split()) map(int, raw_input().split()) x
def euclideanAlgorithm(x, y):
    if y == 0: return x
    return euclideanAlgorithm(y, x%y)

# MAIN
x, y = map(int, raw_input().split())
print euclideanAlgorithm(x, y)