#include <stdio.h>

int main(void) {
	int query;
	int i,start,sum;
	int count;
	while(1) {
		scanf("%d",&query);
		if(query==0)break;
		count=0;
		start=0;
		sum=0;
		for(i=1;i<query;i++) {
			sum+=i;
			while(sum>query)sum-=start++;
			if(sum==query)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}