#include using namespace std; #define rep(i,j,n) for(int i=j;i pi; template using vt = vector; template using vvt = vector>; i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));} i64 lcd(i64 n, i64 m) {return (n / gcd(n, m) * m);} int dx[] = {1, 0, -1, 0}; int dy[] = {0, 1, 0, -1}; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, d; cin >> n >> d; vt cnt(n * n * 3 + 1, 0); rep(x, 1, n + 1) { rep(y, 1, n + 1) { cnt[x * x + y * y]++; } } i64 ans = 0; rep(w, 1, n + 1) { rep(z, 1, n + 1) { if(w * w - z * z + d >= 0) ans += cnt[w * w - z * z + d]; } } cout << ans << endl; }