/* 
   AOJ 1241
   Lagrange's Four-Square Theorem

*/
#include<stdio.h>
#include<math.h>


int ans_n;

void dfs_search(int depth, int n, int x)
{
  if(x == 0)
    {
      ans_n++;
      return ;
    }
  if(depth >= 4)
    {
      return ;
    }
  
  int new_x = x - n * n;
  if(n != 1)
    {
      dfs_search(depth, n - 1, x);  
    }
  dfs_search(depth + 1, n, new_x);
  return ;
}

void ans(int x)
{
  int max_sq = (int)sqrt((double)x);
 
  dfs_search(0, max_sq, x);
 
}

int main(void)
{
  int x;
  while(1)
    {
      ans_n = 0;
      scanf("%d", &x);
      if(x == 0)
	{
	  break;
	}
      ans(x);
      printf("%d\n", ans_n);
    }

  return 0;
}