#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int a[32769];
int n;
int main()
{
        rep(i,182)
        {
                rep2(j,i,182)
                {
                        if(i*i+j*j>=32769)break;
                        rep2(k,j,182)
                        {
                                if(i*i+j*j+k*k>=32769)break;
                                rep2(l,k,182)
                                {
                                        if(i*i+j*j+k*k+l*l>=32769)break;
                                        a[i*i+j*j+k*k+l*l]++;
 
                                }
                        }
                }
        }
        while(1)
        {
                cin>>n;
                if(n==0)break;
                cout<<a[n]<<endl;
        }
        return 0;
}