#include<stdio.h>

int NOTE[1010];


int main() {
	int N;
	int buff;
	for (int i = 1; i < 500; i++) {
		for (int j = 1; j < 45; j++) {
			buff = (j + 1)*i + j * (j + 1) / 2;
			if (buff <= 1000)NOTE[buff]++;
		}
	}

	while (1) {
		scanf("%d", &N);
		if (!N)break;
		printf("%d\n", NOTE[N]);

	}





	return 0;
}
