#include<bits/stdc++.h>
using namespace std;
map<string,int> hash;
char s[50123];
int main(){
	int T,cas=0;
	scanf("%d",&T);
	while(T--){
		cas++;
		printf("Case #%d: ",cas);
		scanf("%s",s);
		int len=strlen(s);
		int left=0,right=len-1;
		int ans=0;
		string opt,L;
		opt="";
		L="";
		int num=0;
		hash.clear();
		while(left<right){
			L=L+s[left];
			hash[L]=++num;
			opt=s[right]+opt;
			if(hash[opt]!=0){
				ans+=2;
				L="";
				opt="";
				hash.clear();
				/*
				if(left+1==right)
					break;		
				*/
				left++;
				right--;
				continue;	
			}
			if(left+1==right){
				ans++;
				break;
			}
			left++;
			right--;
		}
		if(left==right)
			ans++;
		printf("%d\n",ans);
	}
	return 0;
}
