local a,b,k = io.read("n","n","n")
for i=math.min(a,b),1,-1 do
    if a % i == 0 and b % i == 0 then
        k = k - 1
        if k == 0 then
            print(i)
            break
        end
    end
end