#include <stdio.h>
#define sum(a, b) ((a+b)*(b+1-a)/2)

int main(void)
{
    int i, j, n, count;

    while(scanf("%d", &n), n)
    {
        count = 0;

        for(i=1; i<n; i++)
            for(j=i+1; j<n; j++)
                if(sum(i, j) == n) count++;

        printf("%d\n", count);
    }

    return 0;
}