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

divisors = [a, b].min.downto(1).each_with_object([]) do |n, arr|
  arr.push(n) if a % n == 0 && b % n == 0
  next unless arr.length == k

  puts arr.last
  break
end
