#include #include #include #include #include #include #include #include #include #include #include #include #include #include #pragma warning(disable:4996) typedef long long ll; #define MIN(a, b) ((a)>(b)? (b): (a)) #define MAX(a, b) ((a)<(b)? (b): (a)) #define LINF 9223300000000000000 #define INF 2140000000 const long long MOD = 1000000007; using namespace std; int main(int argc, char* argv[]) { int N,D; scanf("%d%d", &N, &D); vector a(4004000), b(4004000); int i,j; for(i=1; i<=N; i++) { for(j=1; j<=N; j++) { int tmp=i*i+j*j; if(tmp<4004000) { a[tmp]++; } } } for(i=1; i<=N; i++) { for(j=1; j<=N; j++) { int tmp=i*i-j*j+D; if(tmp>=0) { b[tmp]++; } } } ll sum=0; for(i=1; i<4004000; i++) { sum += (ll)a[i]*b[i]; } printf("%lld\n", sum); return 0; }