arr = (1..999).to_a
arr2 = Array.new(1001, 0)
for x in 2..44
    for y in 0..(arr.length-x)
        sum = arr[y, x].inject(:+)
        break if sum > 1000
        arr2[sum] += 1
    end
end

while true
    n = gets.to_i
    break if n == 0
    puts arr2[n]
end
