#include #include using namespace std; typedef long long ll; int N,D; ll A[5000010] = {},B[5000010] = {}; int main(){ cin >> N >> D; // unordered_map m2; for(int i=1;i<=N;i++){ for(int j=1;j<=N;j++){ A[i*i+j*j]++; B[i*i-j*j+N*N]++; } } ll ans = 0; for(int i=1;i<=2*N*N;i++){ if(D-i+N*N>=0) ans += A[i]*B[D-i+N*N]; } cout << ans << endl; }