loop do
  n = gets.chomp.to_i
  break if n==0
  ans = 0
  for i in 0...n
    for j in (i+1)...n
      t = (j*(j+1) - i*(i+1))/2
      if t==n
        ans+=1
      end
      break if t>=n
    end
  end
  puts ans
end