#include<iostream>
using namespace std;

int main(){
	int n;

	while(1){
		int ans =0, p = 0;
		cin >> n;

		if(n == 0) break;

		for(int i=1; i < n; i++){
			p = 0;
			for(int j = i; j < n; j++){
				p += j;

				if(p == n) ans++;
			}
		}

		cout << ans << endl;
	}
}