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
      break if y-x<=1
      ptn += 1 if (y-x)%2==1
    end
    x += 1
  end

  puts ptn
end