#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
int sum(int);
int main() {
	int n;
	for (; ~fscanf(stdin, "%d", &n), n != 0;fprintf(stdout, "%d\n",sum(n)));
	return 0;
}

int sum(int n){
	int i, j,s=0,c=0;
	for (i = 1; i < (n / 2) + 1; i++) 
		for (j = i, s = 0; s < n; j++) {
			s += j; if (s == n)c++;
		}
	return c;
}