class Calculator
    def calc(n)
        max = (n / 2).floor + 1
        addNext = proc do |current, m|
            if(current > n)
                false
            elsif(current == n)
                true
            else
                addNext.call(current + m, m + 1)
            end
        end

        foundArr = []
        for num in 1...max do
            if addNext.call(num, num + 1)
                foundArr.push num
            end
        end
        foundArr.size
    end
end

calculator = Calculator.new()

while true do
    n = gets.chomp!.to_i
    if(n == 0)
        break
    end
    puts calculator.calc(n)
end
