// Probrem B
// Advice from Mr.S
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void)
{
unsigned long a,b,c,d,i,j,k,m,n,x,y,z,count,flag;
while(1){
scanf("%d", &n);
if(n==0) break;
// printf("%d\n", n);
count=0;
x=sqrt((unsigned long)n); // 2^15=32768のときに桁あふれをするのでキャストしておく
// printf("sqrt(%d)=%d\n", n, x);
for(a=0; a<=x; a++){
for(b=a; b<=x; b++){
for(c=b; c<=x; c++){
for(d=c; d<=x; d++){
y=a*a+b*b+c*c+d*d;
if(y==n){
// printf("%d %d %d %d\n", a, b, c, d);
count++;
}
}
}
}
}
// printf("count=%d\n\n", count);
printf("%d\n", count);
}
printf("\n");
return(0);
}