#include <stdio.h>
int main(){
 
  int e,a,n,m,result;
 
  while(1){
 
    result=0;
    scanf("%d",&e);
    e *= 2;
    if(e == 0) break;
 
    for(n = 2; n < 50; n++){
 
      a=e-n*n;
 
      if(a > 0 && a%n == 0 && a/n%2 == 1) result++;
 
    }
 
    printf("%d\n",result);
 
  }
 
  return 0;
 
}