#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; const ll inf = (1 << 30) - 1; const ll infll = (1LL << 61) - 1; ll n, d, ans; int main() { cin >> n >> d; vector X(3 * n * n); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { X[i * i + j * j]++; } } for (int i = 1; i <= n; i++) { for (int j = 0; j <= n; j++) { int x = i * i - j * j + d; if (x >= 0) ans += X[x]; } } cout << ans << endl; }