#include <stdio.h>

int main(void){
	int n;
	int i,j;
	int counter;
	while(1){
		scanf("%d",&n);
		if(n == 0){break;}
		counter = 0;
		for(i = 1; i <= n; i++){
			for(j = 2; i + j - 1 <= n; j++){
				if( (i * 2 + j - 1) * j / 2 == n){
					counter++;
					break;
				}
			}
		}
		printf("%d\n",counter);
	}
	return 0;
}