A,B,K = gets.split(" ").map{|i|i.to_i}

lst = []
(1..100).each do |j|
    if A%j == 0 && B%j == 0 then
         lst.push(j)
    end

    if lst.length >= K then
        break
    end
end 

puts lst[K-1]