#include<stdio.h>

int sum(int a, int b){
    return (a + b)*(b-a+1)/2;
}


int main(void){
    int ans = 0;
    int n;
    int i = 1;
    int j = 2;

    
    while(1){
        scanf("%d",&n);
        if(n == 0) break;
        ans = 0;    
        while(i <= n/2){  
            while(sum(i,j)<=n){
                if(sum(i,j) == n){
                    ans++;
                }
                j++;
           }
           i++;
        }
        printf("%d\n",ans);
    }

    return 0;
}