#include #include using namespace std; int main(){ int N, D; cin >> N >> D; int ans = 0; map dp; for(int x = 1; x <= N; ++x){ for(int w = 1; w <= N; ++w){ ++dp[x*x-w*w]; } } for(int y = 1; y <= N; ++y){ for(int z = 1; z <= N; ++z){ //if(y*y + z*z > D) break; int d = D - y*y - z*z; ans += dp[d]; } } cout << ans << endl; }