args = gets.split(" ").map(&:to_i)

input_a = args[0]
input_b = args[1]
input_K = args[2]

calc_divisor = lambda{|input| (1..input).select do |i|
                                 input.modulo(i) == 0
                              end}
if (input_a <= input_b)
  divisors_list = calc_divisor.call(input_a)
  
  res = divisors_list.select{|div| input_b.modulo(div)}.sort.reverse
else
  divisors_list = calc_divisor.call(input_b)
  res = divisors_list.select{|div| input_a.modulo(div)}.sort.reverse
end

puts res.at(input_K - 1)