#include <stdio.h>

int main()
{
  int i, j;
  int n;
  int sum;
  int count;
  
  while (1) {
    scanf("%d", &n);
    if (n == 0) break;
    count = 0;
    for (i = 0; i < n/2; i++) {
      sum = 0;
      for (j = i + 1; j < n; j++) {
        sum += j;
        if (sum > n) break;
        if (sum == n) {
          count++;
          break;
        }
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

    
  

