#include <iostream> #include <vector> #include <map> #include <unordered_map> #include <set> #include <queue> #include <string> #include <iomanip> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; int MOD = 1000000007; int mp[8001000]; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N, D; cin >> N >> D; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { int t = i * i - j * j + D; if (t < 0)break; mp[t]++; } } long long res = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { res += (long long)mp[i * i + j * j]; } } cout << res << endl; }