#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long LL;

const LL magic = 1000000007;
LL power[50010];
LL hash[50010];

void gao(LL hash[], string str)
{
    int n = str.size();
    hash[0] = str[0];
    power[0] = 1;
    for (int i = 1; i < n; i++)
    {
        hash[i] = hash[i-1] * magic + str[i];
        power[i] = power[i-1] * magic;
    }
}
unsigned long long get(int l, int r)
{
    return hash[r] - (l == 0 ? 0 : hash[l-1] * power[r - l + 1]);
}

int main()
{
	ios::sync_with_stdio(false);
	int T;
	cin >> T;
	for (int cas = 1; cas <= T; cas++) {
		string str;
		cin >> str;
		gao(hash, str);
		int len = str.length();
		int left = 0, right = len - 1;
		int L = 0, R = len - 1;
		int ans = 0;
		while (L < R) {
			if (get(left, L) == get(R, right)) {
				ans += 2;
				left = ++L;
				right = --R;
			}
			else{
				if (L + 1 == R) ans++;
				++L, --R;
			}
		}
		if (L == R) ans++;
		printf("Case #%d: %d\n", cas, ans);
	}
	return 0;
}
