#include using namespace std; long long gcd(long long x, long long y) { if (y == 0) return x; return gcd(y, x % y); } long long lcm(long long x, long long y) { if (x == 0 || y == 0) return 0; return x / gcd(x, y) * y; } int dfs(string s, int l, int r, int cnt) { //cout << s.substr(l, r - l + 1) << endl //<< " " << l << " " << r << " " << cnt << endl; if (l == r && cnt >= 2) return cnt + 1; if (r - l < 2) return s[r] != s[l] ? cnt + 1 : cnt + 2; if (cnt > 0 && s[l] != s[r]) return max(max(dfs(s, l + 1, r, 0), dfs(s, l, r - 1, 0)), dfs(s, l + 1, r - 1, cnt)); else if (s[l] == s[r]) return dfs(s, l + 1, r - 1, cnt + 2); else return max(dfs(s, l + 1, r, 0), dfs(s, l, r - 1, 0)); } int main() { string S; cin >> S; int N = S.size(); cout << dfs(S, 0, N - 1, 0) << endl; }