#include <stdio.h>
int main(){
    int input;
    int i,j, cnt, sum;
    while(1){
        cnt = 0;
        scanf("%d\n",&input);
        if(input == 0) break;
        for(i=1;i<input;++i){
            sum = i;
            for(j=i+1;;++j){
                sum += j;
                if(sum > input) break;
                else if(sum == input) {
                    ++cnt;
                    break;
                }
            }
        }
        printf("%d\n", cnt);
    }
}