local DBG = false
local function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end

local N = io.read("n")
local lim = math.ceil(N^0.5)
local ans = 0
dbgpr(lim)
for k=lim,1,-1 do
    dbgpr(k)
    if N % k == 0 then
        local d = N // k
        local m = d - 1
        if m > 0 and (N // m == N % m) then
            dbgpr("OK", k, d, m)
            ans = ans + m
        end
    end
end
print(ans)