#include "bits/stdc++.h" using namespace std; using ll = long long; using ull = unsigned long long; //#define int ll using vb = vector; using vvb = vector; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; template using V = vector; template using vv = vector>; template using VV = vector>; #define fi first #define se second #define maxs(x,y) (x=max(x,y)) #define mins(x,y) (x=min(x,y)) using pii = pair; using pll = pair; #define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i) #define REP(i,n) FOR(i,0,n) #define RFOR(i,a,b) for(ll i = (ll)(b)-1;i >= a;--i) #define RREP(i,n) RFOR(i,0,n) #define ALL(obj) (obj).begin(), (obj).end() #define rALL(obj) (obj).rbegin(), (obj).rend() #define eb(val) emplace_back(val) const double PI = acos(-1); const double EPS = 1e-10; const ll MOD = 1e9+7; void cioacc(){//accelerate cin/cout cin.tie(0); ios::sync_with_stdio(false); } signed main(){ int n,d; cin >> n >> d; vi ab; REP(i,n){ int k = (i+1)*(i+1)+d; REP(j,n){ int x = k-(j+1)*(j+1); if(x>=2) ab.eb(x); } } sort(ALL(ab)); ll ans = 0; REP(i,n){ int k = (i+1)*(i+1); REP(j,n){ int x = k+(j+1)*(j+1); ans += upper_bound(ALL(ab),x)-lower_bound(ALL(ab),x); } } cout << ans << endl; }