#include using namespace std; typedef long long ll; #define pb push_back #define fi first #define se second typedef pair P; #define Mod 1000000007 using VP = vector

; using VVP = vector; using VI = vector; using VVI = vector; using VVVI = vector; int main(){ ll i,j; ll n; vector v(8000080,0); cin>>n; ll d; cin>>d; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ v[i*i+j*j]++; } } ll ans=0; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ ll r=d+i*i-j*j; if(r>=0&&r<=8000060){ ans+=v[r]; } } } cout<