#include<stdio.h>
int cost(char *);
int main()
{
char s[100][201];
int t,i=0;
scanf("%d",&t);
while(i<t)
{
scanf("%s",s[i]);
i++;
}
for(i=0;i<t;i++)
{
printf("%d\n",cost(s[i]));
}
return 0;
}
int cost(char s)
{
int i=0,ch,j=0,price;
int alphaC[26]={0},alphaS[26]={0};
while((s+i)!=’\0’)
{
ch=0;
if((s+i)>=65&&(s+i)<90)
{
ch=(s+i)-65;
alphaC[ch]++;
}
if((s+i)>=97&&(s+i)<=122)
{
ch=(s+i)-97;
alphaS[ch]++;
}
i++;
}
price=0;
for(i=0;i<26;i++)
{
if(alphaS[i]==0||alphaC[i]==0)
continue;
else
{
j=alphaC[i];
price+=j/2+j%2;
j=alphaS[i];
price+=j/2+j%2;
}
}
return price;
}