loop do
  n = gets.to_i
  if n == 0 then exit end
  cnt = 0

  for i in 1 .. n / 2
    for a in 1 .. n / i
      if n == a * i + (a * (a - 1)) / 2
        cnt += 1
        :found
      end
    end
  end

  puts cnt
end
