#include using namespace std; typedef long long ll; int main() { double N; ll D; cin >> N >> D; int ans = 0; for(int w = 1; w <= N; w++) { for(int x = 1; x <= min(N,sqrt(w*w + D)); x++) { for(int y = 1; y <= min(N,sqrt(w*w + D - x*x)); y++) { for(int z = 1; z <= min(N,sqrt(w*w + D - x*x - y*y)); z++) { if(x*x + y*y + z*z == w*w + D) { ans++; } } } } } cout << ans << endl; }