#include #include using namespace std; typedef long long ll; int N,D; int main(){ cin >> N >> D; unordered_map m1,m2; for(int i=1;i<=N;i++){ for(int j=1;j<=N;j++){ m1[i*i+j*j]++; m2[i*i-j*j]++; } } ll ans = 0; for(auto x:m1){ if(m2.count(D-x.first)) ans += x.second*m2[D-x.first]; } cout << ans << endl; }