include Math
while true
  n = gets.to_i
  break if n==0

  s = 2*n
  x = 2  
  ptn = 0
  while x<sqrt(s)
    if s%x == 0
      k2 = s/x-x+1
      ptn += 1 if k2>0 && k2%2==0
    end
    x += 1
  end

  puts ptn
end