n = gets.chomp.to_i

ary = []
sqrt = (n**(1/2.0)).floor
for i in 1..sqrt
    if n % i == 0
        ary << i
    end
end
ary_reverse = ary.reverse()
ary_reverse.each do |item|
    ary << n/item
end

sum = 0
ary.each do |num|
    if num == 1
        next
    end
    okiniiri = num-1
    syo = n/okiniiri
    amari = n%okiniiri
    # p [syo, amari]
    if syo == amari
        sum += okiniiri
    end
end
puts sum
# ary.length.times do |i|
#     if i != 0
#         if ary[i] - ary[i-1] != 1
#             # p ary[i]
#             sum += ary[i] - 1
#         end
#     end
# end