#include <stdio.h>

int main(void){
    int num,a,sign,sum,temp,t;
    for(;t=0,sum=0,sign=1,scanf("%d",&num),num;){
        a=num/2+1;
        if(num == 1 || num == 2)
            sign=0;
        while(sum=0,temp=a,sign){
            while(temp){
                sum+=temp;
                if(sum == num){
                    t++;
                    break;
                }
                else if(sum > num)
                    break;
                temp--;
                if(temp == 0)
                    sign=0;
            }
            a--;
        }
        printf("%d\n",t);
    }
    return 0;
}