var s,t:ansistring;
n,op:longint;
p:array[..] of longint;
procedure pre;
var i:longint;
begin
s:='$*';
for i:= to length(t) do
begin
s:=s+t[i]+'*';
end;
s:=s+'#';
n:=length(s);
end;
function min(a,b:longint):longint;
begin
if a<b then exit(a) else exit(b);
end;
procedure manacher;
var i,mx,id:longint;
begin
fillchar(p,sizeof(p),);
mx:=; id:=; p[]:=;
for i:= to n do
begin
p[i]:=;
if mx>i then p[i]:=min(mx-i,p[id*-i]);
while s[i+p[i]]=s[i-p[i]] do inc(p[i]);
if p[i]+i>mx then begin mx:=p[i]+i; id:=i; end;
end;
end;
procedure print;
var ans,i:longint;
begin
//writeln(s);
ans:=;
for i:= to n do if p[i]->ans then ans:=p[i]-;
writeln('Case ',op,': ',ans);
end;
begin
op:=;
while true do
begin
inc(op);
t:='';
readln(t);
if t='END' then break;
pre;
manacher;
print;
end;
end.