#include #define EM 1000000 using namespace std; using LL = long long; using P = pair; LL LINF = 1e18; int INF = 1e9; LL mod = 1e9+7; using vint = vector; using vLL = vector; using vvint = vector>; using vvLL = vector>; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } int main(){ int N, D; cin >> N >> D; vector le(1e7, 0), ri(1e7, 0); for(int x = 1;x <= N;x++){ for(int y = 1;y <= N;y++){ le[x*x + y*y]++; } } for(int z = 1;z <= N;z++){ for(int w = 1;w <= N;w++){ int id = w*w - z*z + D; if(id > 0) ri[id]++; } } LL ans = 0; for(int i = 2;i <= 1e7;i++){ ans += le[i]*ri[i]; } cout << ans << endl; }