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