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

numbers = []
for i in 1..[a, b].min
  if (a % i == 0 && b % i == 0)
    numbers.push(i)
  end
end
numbers.sort! {|a, b| b <=> a }
print("#{numbers[k-1]}\n")