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