info=gets.chomp.split(" ").map(&:to_i)
count=0
(0..(info[0]<info[1] ?info[1]: info[0])).reverse_each do|i|
	if(info[0]% i==0 and info[1]% i==0)
		count+=1
		if(count==info[2])
			print i
			break
		end
	end
end