#include using namespace std; //vectora; int table[97][53][113][117]; void h(int x){ if(x < 0){ x += (97*53*113*117); } table[x%97][x%53][x%113][x%117]++; } int f(int x){ if(x < 0){ x += (97*53*113*117); } return table[x%97][x%53][x%113][x%117]; } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, d; cin >> n >> d; int ptr = 0; for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ h(i*i - j*j); } } long long ans = 0; for(int i=1; i<=n; i++){ for(int j=1; j<=n; j++){ ans += f(i*i + j*j - d); } } cout << ans << endl; }