#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef unsigned long long ULL;
const int N = 1000010, P = 131;
char str[N];
ULL h1[N],h2[N],p[N];
ULL hash1(int l,int r){return h1[r]-h1[l-1]*p[r-l+1];}
ULL hash2(int l,int r){return h2[l]-h2[r+1]*p[r-l+1];}
int main()
{
p[0]=1;
for(int i=1;i<1000000;i++) p[i]=p[i-1]*P;
int T=1;
while(scanf("%s",str+1),strcmp(str+1,"END"))
{
int len=strlen(str+1);
h2[len+1]=0;
for(int i=1;i<=len;i++) h1[i]=h1[i-1]*P+(str[i]-'a'+1);
for(int i=len;i>=1;i--) h2[i]=h2[i+1]*P+(str[i]-'a'+1);
int ans=0;
for(int i=1;i<=len;i++)
{
int l=0,r=min(i-1,len-i);
while(l<r)
{
int mid=(l+r+1)>>1;
if(hash1(i-mid,i-1)==hash2(i+1,i+mid)) l=mid;
else r=mid-1;
}
ans=max(ans,l<<1|1);
l=0,r=min(i-1,len-i+1);
while(l<r)
{
int mid=(l+r+1)>>1;
if(hash1(i-mid,i-1)==hash2(i,i+mid-1)) l=mid;
else r=mid-1;
}
ans=max(ans,l<<1);
}
printf("Case %d: %d\n",T++,ans);
}
return 0;
}