#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define num 255
#define true 1
#define false 0

void square();
int check(int left);

int *p;
int N;

int main(){
  p = (int *)malloc(num);
  square();

  while(scanf("%d",&N),N){
    int count=0;
    int i,j,m,left;

    for(i=0;4*p[i]<=N;i++){
      for(j=i;p[i]+3*p[j]<=N;j++){
        for(m=j;p[i]+p[j]+2*p[m]<=N;m++){
          left = N - p[i] - p[j] - p[m];
          if (check(left)) count++;
          }
        }
      }
    printf("%d\n",count );
  }

  free(p);
  exit(0);
}

void square(){
  for(int i=0;i<num;i++){
    p[i]=i*i;
  }
}

int check(int left){
  if(sqrt((double)left)-floor(sqrt((double)left))<1e-8){
    return true;
  }
  return false;
}

