s = Array.new(1001,  0)
1.upto(999) do |i|
    sum = i
    (i+1).upto(1000) do |j|
        sum += j
        break if sum > 1000
        s[sum] += 1
    end
end
loop do
    n = gets.to_i
    break if n == 0
    puts s[n]
end