#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define INF (2000000000)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;


int dp[5][100001];

int main()
{
	dp[0][0] = 1;
	for (int i = 1; i <= 400; i++){
		for (int j = 1; j <= 4; j++){
			for (int k = i * i; k <= 100000; k++){
				dp[j][k] += dp[j - 1][k - i * i];
			}
		}
	}
	
	int n;
	while (scanf("%d", &n), n){
		int sum = 0;
		for (int i = 1; i <= 4; i++){
			sum += dp[i][n];
		}
		
		printf("%d\n", sum);
	}
	
	return 0;
}