#include <stdio.h>

int main(void)
{
	int n, sum, cnt;
	int i, j;

	while (1) {
		scanf("%d", &n);
		if (n == 0)
			break;
		cnt = 0;
		for (i = 1; i <= n / 2; i++) {
			sum = 0;
			for (j = i; j < n; j++) {
				sum += j;
				if (sum >= n)
					break;
			}
			if (sum == n)
				cnt++;
		}
		printf("%d\n", cnt);
	}
	return 0;
}
			