#include<stdio.h>

int Calc(int, int);

int main()
{
	int i, N, count;
	
	while(1)
	{
		scanf("%d", &N);
		
		if(N == 0) break;
		
		count = 0;
		
		for(i = 1; i < N / 2 + 1; i++)
		{
			if(Calc(i, N) == N)
			{
				count++;
			}
		}
		
		printf("%d\n", count);
	}
	
	return 0;
}

int Calc(int start, int limit)
{
	int i;
	int result = start;
	
	i = start;
	
	do
	{
		result += ++i;
	} while(result < limit);
	
	return result;
}