#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ull = unsigned long long; const ll INF = 1e16; const ll MOD = 1e9 + 7; #define REP(i, n) for(ll i = 0; i < n; i++) int main() { int n, d; scanf("%d %d", &n, &d); int cnt[8000001] = {}; for(int x = 1; x <= n; x++){ for(int y = 1; y <= n; y++){ cnt[x * x + y * y]++; } } int ans = 0; for(int z = 1; z <= n; z++){ for(int w = 1; w <= n; w++){ int t = w * w - z * z + d; if(t < 1) continue; ans += cnt[t]; } } printf("%d\n", ans); }