#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <time.h>
#include <unordered_map>
#include <cstdlib>
#include <string.h>
#include <bitset>
#include <unordered_set>
#include <cstdlib>
#include <string.h>
#include <cassert>
#define all(a) (a).begin(), (a).end()
#define int long long
using namespace std;
vector<int> sq;
int glob = 0;
void dfs(int n, int sum, int index, int step, int prelast, int last){
if(step == 4){
return;
}
if(prelast != last){
index--;
}
for(int i = index; i >= 1; --i){
int new_el = sum - last * sq[i];
//cerr << new_el << "\n";
if(sum - last * sq[i] == n){
glob++;
}
dfs(n, new_el, i, step + 1, last, -1);
dfs(n, new_el, i, step + 1, last, 1);
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
int n;
cin >> n;
sq.clear();
for(int i = 0; i * i <= n; ++i){
sq.push_back(i * i);
}
if(n == 0){
cout << "1\n";
return 0;
}
dfs(n, 0, sq.size() - 1, 0, -1, -1);
cout << glob << "\n";
}