#include <iostream>
#include <cmath>

using namespace std;

int solve(int n){
    int res = 0;
    for(int x=0; x*x <= n - x; ++x){
        for(int y=x; x*x + y*y <= n - x - y; ++y){
            for(int z=y; x*x + y*y + z*z <= n - x - y - z; ++z){
                int w = sqrt(n - x*x - y*y - z*z);
                res += z <= w && x*x + y*y + z*z + w*w == n;
            }
        }
    }
    return res;
}

int main(){
    for(int n; cin >> n, n; cout << solve(n) << '\n');
    return 0;
}