#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; map mp; int binary_search(int x){ auto itr = lower_bound(all(e), x); if(x==*itr)return mp[x]; else return 0; } int main(){ cin >> n >> d; vector a(n); vector b(n); REP(i,n){ a[i]=b[i]=i+1; } e.resize(n*n); REP(i,n){ REP(j,n){ int c = a[i]*a[i]+b[j]*b[j]; e[i*n+j] = c; auto itr = mp.find(c); if(itr!=mp.end()){ mp[c]++; }else{ mp[c]=1; } } } SORT(e); ll res = 0; REP(i,n){ REP(j,n){ int x = d+(i+1)*(i+1)-(j+1)*(j+1); res+=binary_search(x); } } put(res); return 0; }