a,b,k = gets.chomp.split(' ').map(&:to_i)

m = 0
ans = []

if a > b
	m = a
else
	m = b
end

(1..m).each do |i|
	if (a % i) == 0
		if (b % i) == 0
			ans << i
		end
	end
end

ans.sort.reverse!

puts ans[k-1]