#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main(){ string S; cin >> S; assert(S.size() <= 5000); for (auto x : S) assert('a' <= x && x <= 'z'); reverse(S.begin(), S.end()); int N = S.size(); vector> ok(N+1, vector(N+1)); for (int i=N; i>=1; i--){ for (int j=i; j<=N; j++){ ok[i][j] = (S[i-1] == S[j-1]); if (i+1 <= j-1) ok[i][j] = (ok[i][j] & ok[i+1][j-1]); } } vector dp(N+1); dp[0] = 1e9; for (int i=1; i<=N; i++){ for (int j=0; j