N = gets.to_i sum = N * (N - 1) / 2 ans = 0 1.upto(Math.sqrt(N).floor) {|i| if N % i == 0 if sum % i == 0 ans += i end if sum % (N / i) == 0 and i != N / i ans += N / i end end } puts ans