#include <stdio.h>

int count;

int main(void)
{
    int N;
    int i, j;
    int sum;
    int count;
    
    while (1){
        scanf("%d", &N);
        if (N == 0){
            break;
        }
        
        count = 0;
        for (i = 1; i <= 499; i++){
            sum = i;
            for (j = i + 1; j <= 500; j++){
                sum += j;
                if (sum > N){
                    break;
                }
                if (sum == N){
                    count++;
                    break;
                }
            }
        }
        printf("%d\n", count);
    }

    return (0);
}




        