counter = [0] * 1001
(1..499).each do |i|
  counter[i + (i + 1)] += 1
end

(3..50).each do |i|
  (1..1000/i).each do |s|
    k = s
    num = 0
    i.times{ num += k; k += 1}
    break if num > 1000
    counter[j] += 1
  end
end

while n = gets.to_i
  break if n == 0
  p counter[n]
end