for _ in range(int(input())):
word = input()
days = 1
memory = set()
for l in word:
memory.add(l)
if len(memory) > 3:
memory.clear()
memory.add(l)
days += 1
print(days)
#include<iostream>
#include<string>
using namespace std;
int main()
{
long long q,n,t;
string a;
char x,y,z;
cin>>q;
while(q--)
{
x=y=z=' ';
t=0;
cin>>a;
for(int i=0;i<a.size();i++)
{
if(x==' '&&y==' '&&z==' ')x=a[i];
else if(x!=' '&&y==' '&&z==' '&&a[i]!=x)y=a[i];
else if(x!=' '&&y!=' '&&z==' '&&a[i]!=x&&a[i]!=y)z=a[i];
else if(x!=' '&&y!=' '&&z!=' '&&a[i]!=x&&a[i]!=y&&a[i]!=z)
{
t++;
z=y=' ';
x=a[i];
}
}
if(x!=' '||y!=' '||z!=' ')t++;
cout<<t<<'\n';
}
}
1536A - Omkar and Bad Story | 1509A - Average Height |
1506C - Double-ended Strings | 340A - The Wall |
377A - Maze | 500A - New Year Transportation |
908D - New Year and Arbitrary Arrangement | 199A - Hexadecimal's theorem |
519C - A and B and Team Training | 631A - Interview |
961B - Lecture Sleep | 522A - Reposts |
1166D - Cute Sequences | 1176A - Divide it |
1527A - And Then There Were K | 1618E - Singers' Tour |
1560B - Who's Opposite | 182B - Vasya's Calendar |
934A - A Compatible Pair | 1618F - Reverse |
1684C - Column Swapping | 57C - Array |
1713D - Tournament Countdown | 33A - What is for dinner |
810A - Straight A | 1433C - Dominant Piranha |
633A - Ebony and Ivory | 1196A - Three Piles of Candies |
299A - Ksusha and Array | 448B - Suffix Structures |