#include <bits/stdc++.h>
using namespace std;

using ll = long long int;
using P = pair<ll, ll>;
using P3 = pair<double,P>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;
constexpr ll MOD = ll(1e9) + 7;
constexpr int di[] = {0, 1, 0, -1};
constexpr int dj[] = {1, 0, -1, 0};
constexpr double EPS = 1e-8;

int rec(int x, int y, int c){
    if(c == 0){
        return x==0;
    }
    if(x < y*y) return 0;
    int res = 0;
    for(int i=y;i*i<=x;i++){
        res += rec(x-i*i, i, c-1);
    }
    return res;
}

int solve(){
    int n;
    cin >> n;
    if(n == 0) return 1;
    cout << rec(n, 0, 4) << endl;
    return 0;
}

int main(){
    // solve();
    while(solve()==0);
    // int t; cin >> t; for(;t>0;t--) solve();
    return 0;
}
