#include <stdio.h>

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