#include<stdio.h>

int main()
{
    int i, n, cnt = 0, sum = 0;
    while(1){
        scanf("%d", &n);
        if( n == 0 ) break;

        for ( i = 0; i < n; i++ , sum = 0){
            int j = i + 1;
            while(sum < n){
                sum += j++;
            }
            if( sum > n ) continue;
            cnt++;
        }
        printf("%d\n", cnt - 1); //??£?¶???????????????????????????????????????????????????????n)
        cnt = 0;
    }
    return 0;
}