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

array1 = []
array2 = []
a.times.each do |i|
  if a % (i + 1) == 0
    array1 << i + 1
  end
end

b.times.each do |j|
  if b % (j + 1) == 0
    array2 << j + 1
  end
end

array3 = []
array3 = array1 & array2

puts array3[-k]
