def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min)


a, b = map(int, input().split(" "))
if a > b:
    print(Euclid(a, b))
else:
    print(Euclid(b, a)) def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min) Euclid if max % min == 0:
        return min
    else:
        return Euclid(min, max % min) max % min == 0 max % min max min 0 return min min return Euclid(min, max % min) Euclid(min, max % min) Euclid min max % min max min max max min min a, b = map(int, input().split(" ")) a map(int, input().split(" ")) map int input().split(" ") ().split () input split " " b if a > b:
    print(Euclid(a, b))
else:
    print(Euclid(b, a)) a > b a b print(Euclid(a, b)) print Euclid(a, b) Euclid a b print(Euclid(b, a)) print Euclid(b, a) Euclid b a def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min) def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min) Euclid a, b = map(int, input().split(" ")) map(int, input().split(" ")) a b = map(int, input().split(" ")) map(int, input().split(" ")) b
def Euclid(max, min):
    if max % min == 0:
        return min
    else:
        return Euclid(min, max % min)


a, b = map(int, input().split(" "))
if a > b:
    print(Euclid(a, b))
else:
    print(Euclid(b, a))