//Problem Practice B - Counting sheep

#include <string.h>
#include <iostream.h>

void main()
{
	int n, i, m, j, count;
	char S[11];

	cin>>n;
	for(i=1;i<=n;i++){
		cin>>m;
		count=0;
		for(j=0;j<m;j++){		//get word
			cin>>S;
			if(strcmp(S,"sheep")==0)	//tally if equal to "sheep"
				count++;
		}

	//print results
	cout<<"Case "<<i<<": This list contains "<<count<< " sheep."<<endl;
	//print blank line, except for last problem instance
    if (i != n)
      cout << endl;
	}
}
