#include #include #include void solve() { std::string s; std::cin >> s; int n = s.length(); int ans = n; for (int q = 0; q < 2; ++q) { for (int l = 0; l <= n; ++l) { int cost = n - l; for (int i = 0; i < l; ++i) { int j = l - i - 1; if (i >= j) break; if (s[i] != s[j]) cost += 2; } ans = std::min(ans, cost); } std::reverse(s.begin(), s.end()); } std::cout << n - ans << std::endl; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }