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
# p ary
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
puts sum