a, b, k = gets.split.map(&:to_i)
smaller, larger = a >= b ? [b, a] : [a, b]
count = 0
smaller.downto(1) do |i|
  if smaller % i == 0 && larger % i == 0
    count += 1
    if count == k
      puts i
      break
    end
  end
end
