#include #include #include typedef std::int_fast32_t s32; typedef std::uint_fast32_t u32; typedef std::int_fast64_t s64; typedef std::uint_fast64_t u64; const unsigned long mod = 1000000007; std::string str; bool check(int begin, int end2) { for(int i = begin; i <= end2; ++i) { if( str[i] != str[begin + end2 - i] ) return false; } return true; } bool ispa[64][64]; int N; int memo[64]; int dfs(int begin, int max) { if( ispa[begin][N-1] ) return std::max(max, N-1-begin+1); if( memo[begin] >= max ) return memo[begin]; for(int next = N-2; next >= begin; --next) { if( ispa[begin][next] ) { max = std::max(max, next - begin + 1); max = std::max(max, dfs(next+1, max)); } } memo[begin] = max; return max; } int main() { std::cin >> str; std::vector vstr; N = str.size(); for(int i = 0; i < 64; ++i) { memo[i] = -1; } for(int i = 0; i < N; ++i) { for(int j = i; j < N; ++j) { ispa[i][j] = check(i, j); } } ispa[0][N-1] = false; std::cout << dfs(0, 0) << std::endl; return 0; }