import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;
import std.ascii;
import std.bigint;
import std.container;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

const real eps = 1e-10;

void main(){

	while(true) {
		auto n = readInt();
		if(n == 0) return;
		int ans;
		for(int i = 1; i*i <= n; ++i) {
			if(i*i == n) {
				++ans;
				break;
			}
			for(int j = i; i*i+j*j <= n; ++j) {
				if(i*i+j*j == n) {
					++ans;
					break;
				}
				for(int k = j; i*i+j*j+k*k <= n; ++k) {
					if(i*i+j*j+k*k == n) {
						++ans;
						break;
					}
					auto m = n-(i*i+j*j+k*k);
					auto l = 1;
					auto u = m;
					while(l < u) {
						auto x = (l+u)/2;
						if(x*x == m) {
							if(x >= k) {
								++ans;
							}
							break;
						}
						if(x*x < m) {
							l = x+1;
						} else {
							u = x;
						}
					}
				}
			}
		}
		writeln(ans);
	}
}