#include <bits/stdc++.h>
using namespace std;

int main() {
  int N;
  while (cin >> N, N) {
    int ans = 0;
    for (int i = 1; i < N; i++) {
      int c = i, sum = 0;
      while (sum < N) {
        sum += c;
        c++;
      }
      if (sum == N)
        ans++;
    }
    cout << ans << endl;
  }
}