#include <bits/stdc++.h> using namespace std; const int maxn = 3010; string s; int dp[maxn][maxn]; int main() { cin >> s; int len = s.length(); memset(dp, 0, sizeof(dp)); for(int i = len - 1; i >= 0; i --) { dp[i][i] = 1; for(int j = i + 1; j < len; j ++) { if(s[i] == s[j]) dp[i][j] = dp[i + 1][j - 1] + 2; else dp[i][j] = max(dp[i][j - 1], dp[i + 1][j]); } } int ans = dp[0][len - 1]; printf("%d ", ans); return 0; }