#include<iostream>

int main(){
	int n;
	while(std::cin >> n, n){
		int res = 0;
		for(int k=2;k<50;k++){
			int child = 2*n - k*k + k;
			if(child > 0 && child % (2 * k) == 0){
				res++;
			}
		}
		std::cout << res << std::endl;
	}
}