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

int main()
{
  int n, i, j, k, sum, left;

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

    sum = 0;
    for (i = 0; 4 * i*i <= n; i++) {
      for (j = i; i*i + 3 * j*j <= n; j++) {
        for (k = j; i*i + j*j + 2 * k*k <= n; k++) {
          left = n - (i*i + j*j + k*k);
          if (sqrt((double)left) - floor(sqrt((double)left)) < 1e-8) {
            sum++;
          }
        }
      }
    }
    printf("%d\n", sum);
  }
  return 0;
}
