def hoge(a)
    res = []
    i = 1
    while i * i <= a
        if a % i == 0
            res.push(i)
            if i * i != a
                res.push(a / i)
            end
        end
        i += 1
    end
    res.sort!
    return res
end

a, b, k = gets.split.map(&:to_i)
v = hoge(a)
vv = hoge(b)
vvv = v & vv
p vvv[-k]

