#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; int slng, ans; map MAP; bool calc(string s) { int len = s.length(); FOR (i,0,len/2) { if (s[i] != s[len-1-i]) { return false; } } return true; } void dfs(string s, int MAX) { if (MAP.count(s) > 0) { ans = max(ans, MAP[s]); } if(s[0] == 'a') { if (MAX != slng) ans = max(ans, MAX); MAP[s] = ans; return; } FOR(i,0,s.length()){ if(calc(s.substr(0,i+1))){ dfs(s.substr(i+1), max(MAX, i+1)); } } } int main(){ string s; cin >> s; slng = s.length(); s += 'a'; ans = 0; dfs(s,0); cout << ans << endl; return 0; }