#include<stdio.h>

int main() {

	int N;
	int i,j;
	int sum,count;
	int Answer[1000],a=0;

	for(;;) {
		scanf("%d",&N);
		if(N==0) break;

		count=0;
		for(i=1;i<=N/2;i++) {
			sum=0;
			for(j=i;N>sum;j++) {
				sum+=j;
				if(sum==N) {
					count++;
					break;
				}
			}
		}
		Answer[a]=count;
		a++;
	}
	for(i=0;i<a;i++)
		printf("%d\n",Answer[i]);
	return 0;
}