#include "bits/stdc++.h" #define Rep(i,n) for(int i=0;i> a(n,vector(m,0)); using namespace std; typedef long long ll; typedef pair P; template inline bool chmax(T& a, T b) {if(a inline bool chmin(T& a, T b) {if(a>b){a=b;return 1;}return 0;} int n,d; //vector e; unordered_map mp; int main(){ cin >> n >> d; //e.resize(n*n); REP(i,n){ FOR(j,i,n){ if(i==j){ int c = (i+1)*(i+1)+(j+1)*(j+1); //e[i*n+j] = c; auto itr = mp.find(c); if(itr!=mp.end()){ mp[c]++; }else{ mp[c]=1; } }else{ int c = (i+1)*(i+1)+(j+1)*(j+1); //e[i*n+j] = c; auto itr = mp.find(c); if(itr!=mp.end()){ mp[c]+=2; }else{ mp[c]=2; } } /*int c = (i+1)*(i+1)+(j+1)*(j+1); //e[i*n+j] = c; auto itr = mp.find(c); if(itr!=mp.end()){ mp[c]++; }else{ mp[c]=1; }*/ } } ll res = 0; REP(i,n){ REP(j,n){ int x = d+(i+1)*(i+1)-(j+1)*(j+1); auto itr = mp.find(x); if(itr!=mp.end()){ res+=mp[x]; } } } put(res); return 0; }