#include using namespace std; long long cnt[5000010] = {},n,d,ans = 0; int main(){ int i,j; cin >> n >> d; for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ cnt[i*i+j*j]++; } } for(i=1;i<=n;i++){ for(j=1;j<=n;j++){ if(d - i*i + j*j<=0) continue; ans += cnt[d-i*i+j*j]; } } cout << ans << endl; }