#include using namespace std; using Int = long long; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a using namespace __gnu_pbds; template using gmap = cc_hash_table >; //INSERT ABOVE HERE signed main(){ Int n,d; cin>>n>>d; gmap cnt; for(Int i=1;i<=n;i++) for(Int j=1;j<=n;j++) cnt[i*i+j*j]++; Int ans=0; for(Int i=1;i<=n;i++){ for(Int j=1;j<=n;j++){ Int v=i*i-j*j+d; if(v>0) ans+=cnt[v]; } } cout<