N = gets.to_i
divisors = []
(1..(Math.sqrt(N).to_i)).each do |m|
  if N % m == 0
    divisors.push(m)
    divisors.push(N / m) if (m * m != N)
  end
end
ans = 0
divisors.each do |n|
  m = n - 1
  if m > 0 && N / m == N % m
    ans += m
  end
end
puts ans
