c = [0] * 1001
(2..50).each do |i|
  (1..1000/i).each do |j|
    k = j
    num = 0
    i.times{ num += k; k += 1}
    break if num > 1000
    c[num] += 1
  end
end

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