import math
a, b = map(int, input().split())
d = math.gcd(a, b)
uoc = set()
for i in range(1, int(math.sqrt(d)) + 1):
	if d%i == 0:
		uoc.add(i)
		uoc.add(d//i)
dd = list(uoc)
dd.sort(reverse = True)
print(dd[1])