#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

a,b,k=input2()
MAX=max(a,b)
count=0
ans=0
for i in range(MAX,0,-1):
	if a%i==0 and b%i==0:
		count+=1
		if count==k:
			print(i)
			break def input2():
	return map(int,input().split()) input2 return map(int,input().split()) map(int,input().split()) map int input().split() ().split () input split a,b,k=input2() a input2() input2 b k MAX=max(a,b) MAX max(a,b) max a b count=0 count 0 ans=0 ans 0 for i in range(MAX,0,-1):
	if a%i==0 and b%i==0:
		count+=1
		if count==k:
			print(i)
			break i range(MAX,0,-1) range MAX 0 -1 if a%i==0 and b%i==0:
		count+=1
		if count==k:
			print(i)
			break a%i==0 and b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 count+=1 count 1 if count==k:
			print(i)
			break count==k count k print(i) print i break b,k=input2() input2() b ans=0 0 ans count+=1 1 count def input2():
	return map(int,input().split()) def input2():
	return map(int,input().split()) input2 MAX=max(a,b) max(a,b) MAX k=input2() input2() k count=0 0 count a,b,k=input2() input2() a
#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

a,b,k=input2()
MAX=max(a,b)
count=0
ans=0
for i in range(MAX,0,-1):
	if a%i==0 and b%i==0:
		count+=1
		if count==k:
			print(i)
			break