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