#include using namespace std; #define rep(i,n) for(int i = 0; i < (int)n; i++) using ll = long long; int main(){ ll n; cin >> n; n *= n; map mp; for(ll x = 1; x*x <= n; x++) mp[x*x]++; ll ans = 0; for(ll x = 1; x*x <= n; x++) if(mp[n-x*x]) ans++; cout << ans << endl; return 0; }