n1, n2 = int(input()), int(input()) for i in range(min(n1, n2), 0, -1): if n2 % i == 0 and n1 % i == 0: print(i) break