#include <iostream>

using namespace std;

const int N = 1000;
int sum[N];

int main(){
	int n, c;
	for(int i = 0;i < N;++i){
		if (i) sum[i] = sum[i - 1] + (i + 1);
		else sum[i] = i + 1;
	}
	while(cin >> n, n) {
		c = 0;
		for(int i = 2;i < N;++i){
			for(int j = 0;j < i - 1;++j){
				c += (sum[i] - sum[j] == n);
			}
		}
		cout << c << endl;
	}
	return 0;
}

