#include<stdio.h>

int main(){
  int i, j, n, sum, count;

  while(1){
    scanf("%d", &n);
    if(n == 0) break;

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