import std.stdio,std.conv, std.algorithm, std.container;
import std.array,std.range,std.string,std.typecons;
alias ts = to!string;
alias priority_queue = BinaryHeap;
const dx = [1,0,-1,0];
const dy = [0,1,0,-1];
void read(T...)(auto ref T args){
    auto line = readln().split();
    foreach(i,ref arg; args) arg = line[i].to!(typeof(arg));
}
int Sum(int n){return n * (n - 1)/ 2;}
int Sum(int n,int m){return m.Sum - n.Sum;}

void main(){
	int n ;
	while(read(n),n){
		int c;
		foreach(i;2..n){
			if(n - i.Sum < 0) break;
			if((n - i.Sum) % i == 0) c++;
		}
		writeln(c);
	}
}