//中心扩展法
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int expandAroundCenter(string str,int left,int right);
int main() {
string str;
int max = 0;
int bigger;
getline(cin, str);
int len = str.length();
if (len == 0) {
cout << 0;
}
for (int i = 0 ; i < len ; i++) {
int len1 = expandAroundCenter(str, i , i);//以奇数串进行处理,以单个字符串为中心
int len2 = expandAroundCenter(str, i , i+1);//以偶数串进行处理,以相邻两个字符串为中心
bigger = std::max(len1,len2);
if(max < bigger){
max = bigger;
}
}
cout << max;
return 0;
}
int expandAroundCenter(string str,int left,int right){//同时兼容奇数偶数两种情况
while(left >= 0 && right < str.size() && str[left] == str[right]){
left --;
right ++;
}
return right - left - 1;
}