//我明明是暴力解,却居然超过100%用JAVA提交的人,第一次超过100%。运行时间12ms
import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String s=null;
while((s=br.readLine())!=null){
char[] chars=s.toCharArray();
int max=0;
int count=0;
int a=0;
int countsiii=0;
int flag=0;
int count1=1;
int max1=0;
for(int i=0;i<chars.length-1;i++){
//count1=1;
if(chars[i]==chars[i+1]){ count1++;if(max1<count1) max1=count1;}
else count1=1;
}
//System.out.println(max1);
for(int i=0;i<chars.length-1;i++){
count=0;
if(i>=1&&chars[i]==chars[i-1]&&chars[i]==chars[i+1]&&max1>=3&&max1%2==1){countsiii=i-1;flag=3;}
else if(chars[i]==chars[i+1]) {countsiii=i;flag=2;}
else {countsiii=i-1;flag=3;}
for(int j=i+1;j<=chars.length-1;j++){
if(countsiii>=0&&chars[countsiii]==chars[j]){
count++;countsiii--;
if(flag==2){
if(max<2*count){
max=2*count;
}
}
if(flag==3){
if(max<2*count+1){
max=2*count+1;
}
}
}
else break;
}
}
System.out.println(max);
}
}
}