require 'prime'

N = gets.chomp!.to_i
sum = 0

x = Prime.instance.prime_division(N).map {|n, e|
    #puts "#{n},#{e}"
    0.upto(e).map {|i| n ** i }
}
x << [1]

x[0].product(*x[1..-1]) {|x| 
    m = x.inject(1) {|c, x| c *= x } - 1
    next if m == 0
    a = N / m 
    b = N % m
    sum += (a == b ? m : 0)
}

puts sum