if __name__ == "__main__":

    while True:

        n = int(eval(input()))

        if n ==0:break

        nline = [i for i in range(1,n+1)]

        count = 0

        for i in range(n):

            for j in  range(i+1,n):

                if sum(nline[i:j]) > n:break

                if sum(nline[i:j]) == n:count +=1



        print(count)
if __name__ == "__main__":

    while True:

        n = int(eval(input()))

        if n ==0:break

        count = 0

        for i in range(1,n):

            for j in range(i+1,n):

                sum = (i+j)*(j-i+1)/2

                if sum> n:break

                if sum == n:count +=1



        print(count)
if __name__ == "__main__":
    while True:
        n = int(eval(input()))
        if n == 0:
            break
        nline = [i for i in range(1, n + 1)]
        count = 0
        for i in range(n):
            for j in range(i + 1, n):
                if sum(nline[i:j]) > n:
                    break
                if sum(nline[i:j]) == n:
                    count += 1
        print(count)

if __name__ == "__main__":
    while True:
        n = int(eval(input()))
        if n == 0:
            break
        count = 0
        for i in range(1, n):
            for j in range(i + 1, n):
                sum = (i + j) * (j - i + 1) / 2
                if sum > n:
                    break
                if sum == n:
                    count += 1
        print(count)

-        nline = [i for i in range(1, n + 1)] -        for i in range(n): +        for i in range(1, n): -                if sum(nline[i:j]) > n: +                sum = (i + j) * (j - i + 1) / 2 +                if sum > n: -                if sum(nline[i:j]) == n: +                if sum == n: