#include<stdio.h>
main()
{char s[50+1];int b[50],i,k,T,count,n=1;scanf("%d", &T); while(n<=T){scanf("%s", s); k=0;for(i=0; s[i]!='\0'; i++) {switch(s[i]) {case 'A': case 'B': case 'C': b[k++]=2; break;case 'D': case 'E': case 'F': b[k++]=3; break;case 'G': case 'H': case 'I': b[k++]=4; break;case 'J': case 'K': case 'L': b[k++]=5; break;case 'M': case 'N': case 'O': b[k++]=6; break;case 'P': case 'Q': case 'R': case 'S': b[k++]=7; break;case 'T': case 'U': case 'V': b[k++]=8; break;case 'W': case 'X': case 'Y': case 'Z': b[k++]=9; break;}}count=0; for(i=1; i<k; i++)if(b[i]!=b[i-1]) count++; printf("Case #%d: %d\n", n,count);n++; }return 0;
}