#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); string s; cin >> s; int n = s.size(); vector> dp2(n + 1, vector(n + 1)); for(int i = 0; i < n; i++)dp2[i][i] = dp2[i][i + 1] = true; for(int len = 2; len <= n; len++){ for(int l = 0; l + len <= n; l++){ if(s[l] == s[l + len - 1] && dp2[l + 1][l + len - 1])dp2[l][l + len] = true; } } vector dp(n + 1, -1); dp[0] = 1 << 30; for(int i = 0; i < n; i++){ for(int j = i + 1; j <= n; j++){ if(dp2[i][j]) dp[j] = max(dp[j], min(dp[i], j - i)); } } cout << dp[n] << '\n'; }