#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; bool is_kaibun[5010][5010]; string S; int memo[5010][5010]; int N; bool check(int l, int r) { int i = l; int j = r; while (i < j) { if (S[i] != S[j]) return false; ++i; --j; } return true; } int dfs(int l) { if (memo[l][N - 1] != -1) { return memo[l][N - 1]; } if (l >= N) return 9999; int res = 1; for (int r = l; r < N; ++r) { if (not is_kaibun[l][r]) continue; int len = r - l + 1; res = max(res, min(len, dfs(r + 1))); } return memo[l][N - 1] = res; } int main() { memset(is_kaibun, false, sizeof(is_kaibun)); memset(memo, -1, sizeof(memo)); cin >> S; N = S.size(); for (int l = 0; l < N; ++l) { for (int r = l; r < N; ++r) { is_kaibun[l][r] = check(l, r); } } cout << dfs(0) << endl; return 0; }