#include <bits/stdc++.h>
#define FOR(i,j,k) for(int i=(j);i<=(k);++i)
#define NFOR(i,j,k) for(int i=(j);i>=(k);--i)
#define mkp make_pair
#define fst first
#define sec second
#define inl inline
#define pb push_back
#define el_phy_kongroo return 0
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned int ui;
typedef pair< int,int > pii;
inline int read()
{
	int s=0,w=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar();}
	while(ch>='0'&&ch<='9') {s=(s<<1)+(s<<3)+ch-'0',ch=getchar();}
	return s*w;
}
void file()
{
	freopen("alive.in","r",stdin);
	freopen("alive.out","w",stdout);
}
void teltim(int x)
{
	clock_t c1=0;
	if(x) c1=clock();
	else cerr<<endl<<clock()-c1<<"ms"<<endl;
}
const int N=2005;

int n,k;
int nm1[N*N*2];

int main()
{
	//file();
	n=read();k=read();
	FOR(i,1,n) FOR(j,1,n) nm1[i*i+j*j]++;
	ll ans=0;
	FOR(i,1,n) FOR(j,1,n) 
	{
		int x=i*i+k-j*j;
		if(x>=0) ans+=nm1[x];
	}
	printf("%lld",ans);
	el_phy_kongroo;
}