A,B,K=io.read("n","n","n")
function d(a,b)
    if a%b==0 then
        return b
    end
    local c=a%b 
    return d(b,c)
end
local mod=d(A,B)
local count=0
for i=mod,1,-1 do
    if A%i==0 and B%i==0 then
        count=count+1
    end
    if count==K then
        print(i)
        break
    end
end