#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum,count;
  while(1){
  count = 0;
  cin >> n;
  if(n==0) break;
  for(int i=0; i<n; i++){
    sum = 0;
    for(int j=i+1; j<n; j++){
        sum += j;
        if(sum==n) count++;
        if(sum>n) break;
    }
  }
  cout << count << endl;
  }
  return 0;
}
