def gcd(a, b)
  a, b = b, a if a < b
  r = a % b
  r == 0 ? b : gcd(b, r)
end
a, b, k = gets.chomp.split(' ').map(&:to_i)
ab = gcd(a, b)

counter = 0
100.downto(1) do |i|
  counter += 1 if ab % i == 0
  if counter == k
    puts i
    break
  end
end