#include #include using namespace std; #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i ) #define rep(i,n) REP(i,0,n) int main(){ long long N, D; cin >> N >> D; vector c1(8000001), c2(8000001) ; REP(i, 1, N + 1)REP(j, 1, N + 1){ c2[i*i + j*j]++; int s = i*i - j*j + D; if (s >= 1) { c1[s]++; } } long long ans = 0; rep(i, 8000001){ ans += c1[i]*c2[i]; } cout << ans << endl; return 0; }