#include <bits/stdc++.h>
#define MAX (1 << 15)
using namespace std;

int main()
{
	vector<vector<int>> dp(5, vector<int>(MAX + 1, 0));
	dp[0][0] = dp[1][0] = dp[2][0] = dp[3][0] = dp[4][0] = 1;
	for (int i = 1; i * i <= MAX; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k + i * i <= MAX; k++) {
				if (dp[j][k]) {
					dp[j + 1][k + i * i] += dp[j][k];
				}
			}
		}
	}
	int n;
	while (cin >> n, n) {
		cout << dp[4][n] << endl;
	}
	return 0;
}