##templete

n = gets.chomp.to_i

res = 0
list = []

for i in 1..10**6 + 1 do
  if n % i == 0
    list.push(i)
    list.push(n/i)
  end
end

list = list.uniq
for x in list do
  if x != 1 && (n / (x-1) == n % (x-1)) 
    res += x - 1
  end
end

puts res
