n = gets.split
a = n[0].to_i
b = n[1].to_i
k = n[2].to_i

numbers = [a,b]
max = numbers.max {|a2, b2| a2.to_i <=> b2.to_i }
result = []

max.downto(1).each do |i|
  if((a/i) * i == a)
    if((b/i) * i == b)
      result.push(i)
    end
  end
end

p result[k-1]
