#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> l_l; #define EPS (1e-7) #define INF (1e9) #define PI (acos(-1)) //const ll mod = 1000000007; int N, D; ll to[10000000]; int main() { //cout.precision(10); cin.tie(0); ios::sync_with_stdio(false); cin >> N >> D; for(int i = 1; i <= N; i++) { for(int j = 1; j <= N; j++) { int ans = i * i + j * j; to[ans]++; } } ll ans = 0; for(ll x = 1; x <= N; x++) { for(ll w = 1; w <= N; w++) { ll tmp = D + w * w - x * x; if(tmp > 0) ans += to[tmp]; } } cout << ans << endl; return 0; }