
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;

const int NMAX = 1<<16;
vector<int> a;

void ini(){
	for(int i=0; i*i < NMAX ;i++) a.push_back(i*i);
	return;
}

int dfs(int num, int i2, int k){
	if(k==0){
		if(num == 0) return 1;
		return 0;
	}
	int res = 0;
	for(int i=i2; i<a.size() && num>=a[i] ;i++){
		res += dfs(num-a[i], i, k-1);
	}
	return res;
}

bool solve(){
	int n;
	cin>> n;
	if(!n) return false;
	
	cout<< dfs(n,0,4)<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	ini();
	while(solve());
	return 0;
}

 