#include using namespace std; #define INF 8000001 int N, D; int LEFT[INF]; int RIGHT[INF]; int main(){ cin >> N >> D; for(int i = 0; i < INF; ++i){ LEFT[i] = 0; RIGHT[i] = 0; } for(int x = 1;x <= N; ++x){ for(int y = 1; y <= N; ++y){ LEFT[x*x+y*y]++; } } for(int z = 1;z <= N; ++z){ for(int w = 1; w <= N; ++w){ if(w*w-z*z +D >0){ RIGHT[w*w - z*z + D]++; } } } int ans = 0; for(int i = 0; i < INF; ++i){ ans += LEFT[i] * RIGHT[i]; } cout << ans << endl; }