#include <iostream>
using namespace std;
int main(){
	int N;
	while( cin >> N, N ){
		int i, j, sum;
		int ans = 0;
		for( i = (N+1)/2; i > 0; i-- ){
			sum = i;
			for( j = i - 1; j > 0; j-- ){
				sum += j;
				if( sum == N ){
					ans++;
					break;
				}
				if( sum > N ) break;
			}
		}
		cout << ans << endl;
	}
}