line = gets.split(' ').map(&:to_i)
A = line[0]
B = line[1]
K = line[2]

cnt = 0
ret = 0
for i in 1..100 do
    t = 101 - i
    if A % t == 0 and B % t == 0 then
        cnt += 1
        if cnt == K then
            ret = t
            break
        end
    end
end

puts ret
