n = gets.to_i
while n != 0
	cnt = 0
	sum = 0
	sum_cnt = 0
	n.times do |i|
		j = 1 + i
		loop do
			sum += j
			sum_cnt += 1
			j += 1
			#puts sum
			if sum == n  && sum_cnt >= 2
				cnt += 1
				#print("sum = ",sum,"\n")
				break
			elsif sum > n
				break
			end
		end
		sum = 0
		sum_cnt = 0
	end
	puts cnt
	n = gets.to_i 
end