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

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

  puts ptn
end