#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; map mp1, mp2; rep(i, 1, n + 1) { rep(j, 1, n + 1) { mp1[i * i + j * j]++; mp2[i * i - j * j + d]++; } } i64 ans = 0; for(auto &it : mp1) { if(mp2.count(it.first)) { ans += it.second * mp2[it.first]; } } cout << ans << endl; }