#include #include using namespace std; using namespace atcoder; using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; #define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++) #define vi vector #define vl vector #define vvi vector> #define vvl vector> #define pint pair #define plong pair int N, D; vi x2y2; void solve() { x2y2.resize(2000 * 2000 * 2 + 1); REP(x, 1, N + 1) { REP(y, 1, N + 1) { int total = x * x + y * y; x2y2[total]++; } } long ans = 0; REP(w, 1, N + 1) { REP(z, 1, N + 1) { int search = D + w * w - z * z; if(search <= 0) continue; ans += x2y2[search]; } } cout << ans << endl; } int main() { cin >> N >> D; solve(); }