#include <stdio.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int main(){
	ll n;
	while(scanf("%lld",&n),n){
		n*=2;
		ll ans=0;
		rep(i,1,n+1)if(i*i<n&&n%i==0&&i%2!=n/i%2)ans++;
		printf("%lld\n",ans-1);
	}
}
