#include using namespace std; // x^2 + y^2과 w^2 - z^2를 구한다. map cnt1,cnt2; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int n,D; int res = 0; cin >> n >> D; for(int a=1;a<=n;a++) { for(int b=1;b<=n;b++) { cnt1[a*a + b*b]++; cnt2[b*b - a*a]++; } } for(auto it : cnt2) { long long int way = it.second; long long int val = it.first + D; res += (cnt1[val]*way); } cout << res << '\n'; return 0; }