#include #include #include #include #include int main() { std::string str; std::cin >> str; std::vector > v(str.length(),std::vector(str.length(),0)); int max = 0, maxi, maxj; for (int i = 0; i < str.size(); i++) { for (int j = 1; j <= str.size() - i; j++) { std::string s = str.substr(i, j); std::string r = s; std::reverse(r.begin(), r.end()); if (s == r) { v[i][j - 1] = s.length(); if (max < s.length()) { max = s.length(); maxi = i; maxj = j - 1; } } } } v[maxi][maxj] = 0; int secondmax = 0; for (int i = 0; i < v.size(); i++) { secondmax = std::max(secondmax, *std::max_element(v[i].begin(), v[i].end())); } if(max != str.length()){ std::cout << max << std::endl; } else { std::cout << secondmax << std::endl; } return 0; }