#include using namespace std; typedef long long ll; typedef pair pii; typedef vector vi; #define mp make_pair #define pb push_back #define pf push_front #define fi first #define se second #define MOD 1000000007 int MAX = 9e6; int main(){ int n,d; cin >> n >> d; vector cnt1(MAX),cnt2(MAX); for(int i = 1; i < n+1; ++i){ for(int j = 1;j < n+1; ++j){ cnt1[i*i + j*j]++; if(i*i - j*j + d > 0) cnt2[i*i - j*j + d]++; } } ll ans = 0; for(int i = 0; i < MAX; ++i){ ans += cnt1[i]*cnt2[i]; } cout << ans << endl; return 0; }