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

count = 0

[a,b].min.times do |i|
    if (a % (i+1) == 0) && (b % (i+1) == 0)
        count += 1
    end
    if count == k
        puts i + 1
        break
    end
end
