while true
  n = gets.to_i
  break if n==0
  s = 2*n
  x = 1  
  ptn = 0
  while x<n
    if s%x == 0
      y = s/x
      ptn += 1 if x+y>1 && y>x-1 && x+y%2==1
    end
    x += 1
  end

  puts ptn
end