#include<bits/stdc++.h>
#define el '\n'
using namespace std;
using ull = unsigned long long;
template<class T> using ve = vector<T>;
const int N = 1e5+7;
const int base1 = 47;
const int base2 = 107;
const int M1 = 1e9+7;
const int M2 = 1e9+9;
static int tc = 1;
int pw(int a, int b, int m) {
int ans = 1;
while (b) {
if (b&1) ans=1ll*ans*a%m;
a=1ll*a*a%m;
b>>=1;
}
return ans;
}
int inv(int k, int m) { return pw(k,m-2,m); }
ull pack(int x, int y) { return 1ll*2e9*x + 1ll*y; }
struct HS {
int n,base,M;
ve<int> p,bp,ibp;
void init(const string &s, int _base, int _mod) {
n = s.size()-1;
base = _base;
M = _mod;
p.resize(n+1);
bp.resize(n+1);
ibp.resize(n+1);
bp[0] = 1;
for (int i=1; i<=n; i++) {
int d = s[i] - 'a' + 1;
bp[i] = 1ll*bp[i-1]*base%M;
p[i] = (p[i-1] + 1ll*bp[i]*d%M)%M;
}
ibp[n] = inv(bp[n],M);
for (int i=n-1; i>=0; i--) ibp[i] = 1ll*ibp[i+1]*base%M;
}
int get(int l, int r) {
return 1ll*(p[r]-p[l-1]+M)*ibp[l-1]%M;
}
};
struct DHS {
HS sh1, sh2;
void init(const string &s) {
sh1.init(s,base1,M1);
sh2.init(s,base2,M2);
}
ull get(int l, int r) {
return pack(sh1.get(l,r),sh2.get(l,r));
}
};
int n;
string s;
DHS sh;
void solve() {
cin>>s;
n = s.size();
s = '*'+s;
sh.init(s);
int ans = 0, j=1;
for (int i=1; i<=n; i++) {
ull h1 = sh.get(j,i);
ull h2 = sh.get(n-i+1,n-j+1);
if (h1 == h2) ans++, j=i+1;
}
cout << ans << el;
}
signed main() {
ios_base::sync_with_stdio(0); cin.tie(0);
if (fopen("test.inp","r")) freopen("test.inp","r",stdin);
cin>>tc;
while (tc--) solve();
return 0;
}