#include using namespace std; int main() { string S; cin >> S; int N = S.size(); vector V(N); S.insert(S.size(), " "); for (int i = 0, cnt = 1; i < N; i++) { if (S.at(i) != S.at(i + 1)) V.at(i) = cnt, cnt = 1; else cnt++; } for (int i = N - 1; i >= 0; i--) { if (!V.at(i)) V.at(i) = V.at(i + 1); } int ans = 0; for (int i = 0; i + 1 < N; i++) { if (V.at(i) != V.at(i + 1)) ans = max(ans, min(V.at(i), V.at(i + 1)) * 2); } cout << ans << "\n"; }