#include using namespace std; #define INF 1000000000000000000 #define MOD 1000000007 using ll=long long; using Graph=vector>; int main(){ int N,D; cin>>N>>D; vector cnt(8000001,0); for(int i=1;i<=N;i++){ cnt[i*i*2]++; for(int j=i+1;j<=N;j++){ cnt[i*i+j*j]+=2; } } int ans=0; for(int i=1;i<=N;i++){ for(int j=1;j<=N;j++){ int x=i*i-j*j+D; if(x>=0&&x<=8000000){ ans+=cnt[i*i-j*j+D]; } } } cout<