#include <cstdio>
using namespace std;

int dp[5][32769];

int main(){
	dp[0][0] = dp[1][0] = dp[2][0] = dp[3][0] = 1;

	for(int i = 1; i < 200; ++i){
		int t = i * i;

		for(int k = 1; k <= 4; ++k)
		for(int j = t; j <= 32768; ++j){
			dp[k][j] += dp[k-1][j-t];
		}
	}

	int n;
	for(; scanf("%d", &n), n != 0;){
		printf("%d\n", dp[4][n]);
	}
}