#include <iostream>
#include <numeric>

using namespace std;

#define MAX 1<<15

int dp[MAX + 1][5] = {};

int main() {
	dp[0][0] = 1;
	for (int i = 1; i * i <= MAX; ++i)
		for (int j = i * i; j <= MAX; ++j)
			for (int k = 1; k < 5; ++k)
				dp[j][k] += dp[j - i * i][k - 1];
	int n;
	while (cin >> n, n)
	    cout << accumulate(dp[n] + 1, dp[n] + 5, 0) << endl;

	return 0;
}
