/**
 * 
 */
package pandit.codejam;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.Scanner;

/**
 * @author Manu Ram Pandit
 * 
 */
public class DancingWithGooglersUpload {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		FileInputStream fStream = new FileInputStream(
				"input.txt");

		Scanner scanner = new Scanner(new BufferedInputStream(fStream));
		Writer out = new OutputStreamWriter(new FileOutputStream("output.txt"));

		int T = scanner.nextInt();
		int N,S,P,ti;
		int counter = 0;
		for (int count = 1; count <= T; count++) {
			N=scanner.nextInt();
			S = scanner.nextInt();
			counter = 0;
			P = scanner.nextInt();
			for(int i=1;i<=N;i++){
				ti=scanner.nextInt();
				if(ti>=(3*P-2)){
					counter++;
					continue;
				}
				else if(S>0){
					if(P>=2 && ((ti==(3*P-3)) ||(ti==(3*P-4)))) {
					S--;
					counter++;
					continue;
					}
				}
				
			}
			// System.out.println("Case #" + count + ": " + counter);
			out.write("Case #" + count + ": " + counter + "\n");
		}
		fStream.close();
		out.close();

	}

}

import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Scanner;

public class DancingWiththeGooglers {
	final static String FILENAME = "B-small-attempt0";

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new FileReader("/home/workshop/Documents/"
				+ FILENAME + ".in"));
		BufferedWriter bw = new BufferedWriter(new FileWriter(
				"/home/workshop/Documents/" + FILENAME + ".out"));
		int T = sc.nextInt();
		sc.nextLine();
		for (int ttt = 0; ttt < T; ttt++) {
			int N = sc.nextInt();
			int S = sc.nextInt();
			int p = sc.nextInt();

			int s = S, count = 0;
			for (int n = 0; n < N; n++) {
				int t = sc.nextInt();
				switch (t % 3) {
				case 0:
					int z = t / 3; // z, z, z
					if (z >= p)
						count++;
					else if (s > 0 && z + 1 >= p && z - 1 >= 0 && z + 1 <= 10) {
						// z-1, z, z+1 (*)
						count++;
						s--;
					}
					break;
				case 1:
					int x = (t - 1) / 3; // x, x, x+1
					if (x + 1 >= p)
						count++;
					break;
				case 2:
					int y = (t - 2) / 3; // y, y+1, y+1
					if (y + 1 >= p)
						count++;
					else if (s > 0 && y + 2 >= p && y + 2 <= 10) {
						// y, y, y+2 (*)
						count++;
						s--;
					}
					break;
				}
			}

			bw.write("Case #" + (ttt + 1) + ": " + count);
			bw.newLine();
		}
		bw.close();
		sc.close();
	}

}
