#include <bits/stdc++.h>
#define int unsigned long long
using namespace std;
const int N=1e6+7;
const int base=131;
int t;
string s;
int f[N],p[N];
int get(int l,int r){
return f[r]-f[l-1]*p[r-l+1];
}
signed main(){
freopen("palin.in","r",stdin);
freopen("palin.out","w",stdout);
cin>>t;
while(t--){
memset(f,0,sizeof(f));
memset(p,0,sizeof(p));
cin>>s;
p[0]=1;
int n=s.size();
for(int i=1;i<=n;i++){
p[i]=p[i-1]*base;
f[i]=f[i-1]*base+(s[i-1]-'a'+1);
}
int last=0;
int cnt=0;
for(int i=0;i<n/2;i++){
if(get(last+1,i+1)==get(n-i,n-last)){
cnt+=2;
last=i+1;
}
}
if(last<n-last){
cnt++;
}
cout<<cnt<<"\n";
}
return 0;
}