1 var s,t:ansistring; 2 n,op:longint; 3 p:array[0..2000008] of longint; 4 procedure pre; 5 var i:longint; 6 begin 7 s:='$*'; 8 for i:=1 to length(t) do 9 begin 10 s:=s+t[i]+'*'; 11 end; 12 s:=s+'#'; 13 n:=length(s); 14 end; 15 function min(a,b:longint):longint; 16 begin 17 if a<b then exit(a) else exit(b); 18 end; 19 procedure manacher; 20 var i,mx,id:longint; 21 begin 22 fillchar(p,sizeof(p),0); 23 mx:=0; id:=1; p[1]:=1; 24 for i:=2 to n do 25 begin 26 p[i]:=1; 27 if mx>i then p[i]:=min(mx-i,p[id*2-i]); 28 while s[i+p[i]]=s[i-p[i]] do inc(p[i]); 29 if p[i]+i>mx then begin mx:=p[i]+i; id:=i; end; 30 end; 31 end; 32 procedure print; 33 var ans,i:longint; 34 begin 35 //writeln(s); 36 ans:=0; 37 for i:=1 to n do if p[i]-1>ans then ans:=p[i]-1; 38 writeln('Case ',op,': ',ans); 39 end; 40 begin 41 op:=0; 42 while true do 43 begin 44 inc(op); 45 t:=''; 46 readln(t); 47 if t='END' then break; 48 pre; 49 manacher; 50 print; 51 end; 52 end.