import java.io.*;
import java.util.*;

public class B_h {
  public static DataInputStream in = new DataInputStream(System.in);

  public static void main(String[] args) {
    try {
      int n, m, i, j, c;
      String s[] = new String[10];
      n = Integer.parseInt(in.readLine());
      for (i = 0; i < n; i++) {
	m = Integer.parseInt(in.readLine());
	StringTokenizer str = new StringTokenizer(in.readLine());
	c = 0;
	for (j = 0; j < m; j++) {
	  if ((str.nextToken()).equals("sheep")) {
	    c++;
	  }
	}
	if (i > 0) {
	  System.out.println("");
	}
	System.out.println("Case " + (i+1) + ": This list contains " +
			   c + " sheep.");

      }
    } catch (IOException e) {
    }
  }
}

