loop do
  n = gets.to_i
  break if n == 0

  num = 0
  lim = ((n+n%2)/2)
  1.upto(lim-1) do |base|
    (base..lim).inject(0) do |sum, i|
      sum += i
      if ( sum >= n )
        num += 1 if sum == n
        break
      end
      next sum
    end
  end

  puts num
end