num_a,num_b,num_k = gets.split(" ").map!{|i| i.to_i}
list_com = Array.new

count = 1 
while count <= num_a + num_b 
  if num_a%count == 0 && num_b%count == 0
    list_com.push(count)
  end
  count += 1
end

list_com.reverse!
#p list_com
p list_com[num_k-1]