#include<stdio.h>
int main(){

  int i,j,n,count,n2;

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

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