#include<stdio.h> #define N 200 char s[N]; int judgeup(char c) { if(c>='A'&&c<='Z') return 1; return 0; } int judgelo(char c) { if(c>='a'&&c<='z') return 1; return 0; } int main() { int lock,i,j,sum,n,h; scanf("%d",&n); while(n--) { scanf("%s",s); sum=0;lock=0; for(i=0;s[i];i++) { if(lock==0) { if(judgelo(s[i])) { sum++; continue; } h=0; for(j=i;s[j];j++) { if(judgeup(s[j])) h++; else break; } if(h>=2) { sum=sum+1+h; i=j-1; lock=1; } else { sum+=2; i=j-1; } } else { if(judgeup(s[i])) { sum++; continue; } h=0; for(j=i;s[j];j++) { if(judgelo(s[j])) h++; else break; } if(h>=2) { sum=sum+1+h; i=j-1; lock=0; } else { sum+=2; if(s[j]==0)//注意这个这组数据AAaAaAa lock=0; i=j-1; } } } if(lock==1) sum++; printf("%d ",sum); } return 0; }