#include #include #include #include #include #include #include #include #include #include #pragma GCC optimize("O3") #pragma comment(linker, "STACK:36777216") using namespace std; using i64 = int64_t; constexpr i64 MOD = 1e9 + 7; using vi = vector; using vvi = vector; using vvvi = vector; bool is_pal(string s) { string t(s); reverse(t.begin(), t.end()); return s == t; } int main() { string s; cin >> s; int len = 1; if (s.size() == 1) { cout << 1 << endl; return 0; } if (is_pal(s)) { if (is_pal(s.substr(1)) || is_pal(s.substr(0, s.size() - 1))) { cout << s.size() - 1 << endl; return 0; } else { cout << s.size() - 2 << endl; return 0; } } for (int i = 0; i < s.size(); i++) { for (int j = i; j < s.size(); j++) { // cout << s.substr(i, s.size() - j) << endl; if (is_pal(s.substr(i, s.size() - j))) { len = max(len, int(s.size() - j)); } } } cout << len << endl; }