#K-th Common Divisor
A,B,K = gets.chomp.split(" ").map(&:to_i)
max = 0
ans = []
if A >= B
    max = A
else
    max = B
end

for i in 1..max
    if A % i == 0 && B % i == 0
        ans.push(i)
    end
end
puts ans[ans.length-K]