/*
ID: jennife2
LANG: JAVA
TASK: calfflac
*/
import java.io.*;
public class calfflac{
public static int ops = 0;
public static void main(String[] args) throws IOException{
BufferedReader console = new BufferedReader(new FileReader("calfflac.in"));
BufferedWriter out = new BufferedWriter(new PrintWriter(new FileWriter("calfflac.out")));
String s = ""; // string to be handled
String read = "";
int[] st = new int[20000];
int stc = 0;
int counter = 0;
while(console.ready()){
String newline = console.readLine();
read+=newline+"\n";
for(int i=0;i<newline.length();i++){
if ((int)newline.charAt(i)>96&&(int)newline.charAt(i)<123||(int)newline.charAt(i)>64&&(int)newline.charAt(i)<91){
s += newline.charAt(i);
st[stc] = counter;
//System.out.println(newline.charAt(i)+","+counter+" ");
stc++;
}
counter++;
}
counter++;
}
//System.out.print(s);
s = s.toUpperCase();
int longest = 0;
int posLong = 0; // start position of longest palindrome
int z = 1;
// odd length palindromes
for(int i=0; i<s.length();i++){
for(z = 1;i-z>=0&&i+z<s.length()&&s.charAt(i-z)==s.charAt(i+z);z++); // loop through building pal
// z will be one too long
if ((z-1)*2+1>longest){
longest = (z-1)*2+1;
posLong = i-(z-1);
}
}
// even length palindromes
for(int i=0; i<s.length();i++){
for(z = 1;i-z+1>=0&&i+z<s.length()&&s.charAt(i-z+1)==s.charAt(i+z);z++); // loop through building pal
// z will be one too long
if ((z-1)*2>longest||(z-1)*2==longest&&i-(z-1)+1<posLong){
longest = (z-1)*2;
posLong = i-(z-1)+1;
}
}
if (longest>0){
out.write(longest+"\n"+read.substring(st[posLong],st[posLong+longest-1]+1)+"\n");
}
else{
out.write("0\n\n");
}
out.close();
System.exit(0);
}
}