#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ string s; cin >> s; vector> v; char prev = '.'; int cnt = 0; rep(i,s.size()){ if(s[i] != prev){ if(prev != '.') v.push_back(make_pair(prev,cnt)); prev = s[i]; cnt = 1; }else{ cnt++; } } v.push_back(make_pair(prev,cnt)); int ret = 0; rep(i,v.size()-1){ ret = max(ret, min(v[i].second, v[i+1].second)); } REP(i,1,v.size()-1){ if(v[i].second <= v[i-1].second + v[i+1].second){ ret = max(ret, v[i].second); } } cout << ret*2 << endl; return 0; }