#include using namespace std; using ll = long long; ll n, d, ans; int main() { cin >> n >> d; vector X(n * n + d); for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { X[i * i + j * j]++; } } for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { int x = i * i - j * j + d; if (x > 0) ans += X[x]; } } cout << ans << endl; }