#include<stdio.h>


int main(){
	int N, m, sum;
	int i, j, counter;
	int sum_r, sum_rr;
	scanf("%d",&N);
	while(N != 0){
		if((N ==1)||(N==2)){
			printf("0\n");
			goto end;
		}
		sum = 0;
		counter = 0;
		m = N/2+1;
		for(i=1; i<=m; i++)
			sum += i;

		sum_r = sum;
		/*printf("m:%d sum:%d\n", m, sum);*/

		for(i=0; i<m; i++){
			sum_r -= i;
			if(sum_r == N){
				counter++;
				/*printf("iroop: %d\n", i);*/
				break;
			}
			if(sum_r < N)
				break;
		}
		sum_r += i--;
		sum_rr = sum_r;
		while(i >= 0){
			for(j=m; j>0; j--){
				sum_rr -= j;
				if(sum_rr == N){
					counter++;
					/*printf("jroop: %d %d\n", i, j);*/
					break;
				}
				if(sum_rr < N)
					break;
			}
			sum_r += i--;
			sum_rr = sum_r;
		}
		printf("%d\n", counter);
		end:
		scanf("%d", &N);
	}
	return 0;
}