#include using namespace std; #define rep(i, n) for(int i=0; i<(int)(n); i++) #define rep1(i, n) for(int i=1; i<=(int)(n); i++) #define rep2(i, n, m) for(int i=(int)n; i<=(int)m; i++) typedef long long ll; typedef vector vi; typedef vector wi; typedef vector vl; const ll inf=1LL<<60; int main(){ cin.tie(0); ios::sync_with_stdio(false); int x, y; cin >> x >> y; int r=0; while(r*r<=y)r++; r--; vi cnt(y+1); rep1(i, r){ rep(j, r+1){ if(i*i+j*j<=y)cnt[i*i+j*j]++; } } int ans=0; rep2(i, x, y)ans=max(ans, cnt[i]); cout << 4*ans << endl; return 0; }