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

