#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,dem[10005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
cin>>n;
int deml=0;
for(int i=1;i<=10000;i++)
{
ll p=i*i;
ll g=n-p;
if(g<=0) break;
ll x=sqrt(g/2);
for(int j=i;j<=x;j++)
{
ll b=j*j;
ll c=g-b;
if(c<=0) break;
ll t=sqrt(c);
if(c==t*t&&dem[j]==0&&dem[t]==0) deml++;
}
dem[i]=1;
}
cout<<deml;
return 0;
}
I2luY2x1ZGU8Yml0cy9zdGRjKysuaD4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKI2RlZmluZSBsbCBsb25nIGxvbmcKbGwgbixkZW1bMTAwMDVdOwppbnQgbWFpbigpCnsKICAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oZmFsc2UpOwogICAgY2luLnRpZSgwKTtjb3V0LnRpZSgwKTsKICAgIGNpbj4+bjsKICAgIGludCBkZW1sPTA7CiAgICBmb3IoaW50IGk9MTtpPD0xMDAwMDtpKyspCiAgICB7CiAgICAgICAgbGwgcD1pKmk7CiAgICAgICAgbGwgZz1uLXA7CiAgICAgICAgaWYoZzw9MCkgYnJlYWs7CiAgICAgICAgbGwgeD1zcXJ0KGcvMik7CiAgICAgICAgZm9yKGludCBqPWk7ajw9eDtqKyspCiAgICAgICAgewogICAgICAgICAgICBsbCBiPWoqajsKICAgICAgICAgICAgbGwgYz1nLWI7CiAgICAgICAgICAgIGlmKGM8PTApIGJyZWFrOwogICAgICAgICAgICBsbCB0PXNxcnQoYyk7CiAgICAgICAgICAgIGlmKGM9PXQqdCYmZGVtW2pdPT0wJiZkZW1bdF09PTApICBkZW1sKys7CiAgICAgICAgfQogICAgICAgIGRlbVtpXT0xOwogICAgfQogICAgY291dDw8ZGVtbDsKICAgIHJldHVybiAwOwp9IA==