#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int MAX_V = 10010000; int counter[MAX_V]; int main() { int X, Y; cin >> X >> Y; int S, L; S = ceil(sqrt(X)); if (X == Y) { L = S; } else { L = ceil(sqrt(Y)); } assert(MAX_V > L * L); for (int x = 0; x <= L * L; ++x) { counter[x] = 0; } for (int x = S; x <= L; ++x) { int v = x * x; if (v < X) continue; if (v > Y) continue; counter[v] += 1; } for (int y = 0; y < L; ++y) { int dy = y * y; for (int x = 0; x < L; ++x) { int dx = x * x; int v = dy + dx; if (v < X) continue; if (v > Y) continue; counter[v] += 1; } } int ans = 0; for (int x = 0; x <= L * L; ++x) { int value = counter[x]; ans = max(ans, value); } cout << 4 * ans << endl; return 0; }