#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 mp; int main(){ cin >> n >> d; mp.resize(n*n*2+1,0); REP(i,n){ FOR(j,i,n){ if(i==j){ int c = (i+1)*(i+1)+(j+1)*(j+1); mp[c]++; }else{ int c = (i+1)*(i+1)+(j+1)*(j+1); mp[c]+=2; } } } int res = 0; REP(i,n){ REP(j,n){ int x = d+(i+1)*(i+1)-(j+1)*(j+1); if(0<=x&&x<=n*n*2)res+=mp[x]; } } put(res); return 0; }