from collections import deque

if __name__ == '__main__':

	a,b,k = map(int,input().split())

	mini = min(a,b)
	d = deque()
	for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	print(d[k-1])

 from collections import deque if __name__ == '__main__':

	a,b,k = map(int,input().split())

	mini = min(a,b)
	d = deque()
	for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	print(d[k-1]) __name__ == '__main__' __name__ '__main__' a,b,k = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b k mini = min(a,b) mini min(a,b) min a b d = deque() d deque() deque for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	 x range(1,mini+1) range 1 mini+1 mini 1 a2 = a % x a2 a % x a x b2 = b % x b2 b % x b x if a2 == 0 and b2 == 0:
			d.appendleft(x)
	 a2 == 0 and b2 == 0 a2 == 0 a2 0 b2 == 0 b2 0 d.appendleft(x) d.appendleft d appendleft x print(d[k-1]) print d[k-1] d k-1 k 1 b2 = b % x b % x b2 a,b,k = map(int,input().split()) map(int,input().split()) a mini = min(a,b) min(a,b) mini d = deque() deque() d a2 = a % x a % x a2 b,k = map(int,input().split()) map(int,input().split()) b k = map(int,input().split()) map(int,input().split()) k
from collections import deque

if __name__ == '__main__':

	a,b,k = map(int,input().split())

	mini = min(a,b)
	d = deque()
	for x in range(1,mini+1):
		a2 = a % x
		b2 = b % x
		if a2 == 0 and b2 == 0:
			d.appendleft(x)
	print(d[k-1])


