#include using namespace std; void dbg_out() { cerr << endl; } template void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); } #define dbg(...) cerr << "(" << #__VA_ARGS__ << ")", dbg_out(__VA_ARGS__) #define int long long const int MOD = 1e9 + 7; const int INF = LLONG_MAX >> 1; const int N = 4000000, M = 9e6; int cnt[M]; void solve() { int n, d; cin >> n >> d; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { cnt[i * i - j * j + N]++; } } int ans = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int t = d - i * i - j * j + N; if (0 <= t && t < M) { ans += cnt[t]; } } } cout << ans << '\n'; } int32_t main() { ios::sync_with_stdio(false); cin.tie(nullptr); int tc = 1; // cin >> tc; while (tc--) solve(); }