#include using namespace std; #define int long long int N, D; int AB[2222*2222]; signed main() { cin >> N >> D; int cnt = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { AB[cnt] = i*i + j*j; cnt++; } } sort(AB, AB+cnt); int ans = 0; for (int i = 1; i <= N; i++) { for (int j = 1; j <= N; j++) { int num = i*i - j*j + D; int left = lower_bound(AB, AB+cnt, num) - AB; int right = upper_bound(AB, AB+cnt, num) - AB; ans += right - left; } } cout << ans << endl; return 0; }