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