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

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

  puts ptn
end