import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;


public class GooglersDancer {

	/**
	 * @param args
	 * @throws IOException
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		InputStreamReader converter = new InputStreamReader(System.in);
		BufferedReader in = new BufferedReader(converter);
		if (in == null) {
		      return;
		    }
		String numTest = in.readLine();
		int maxCases = Integer.valueOf(numTest);
		for(int i=1;i<= maxCases;i++){
			String linea = in.readLine();
			String[] datos = linea.split(" ");
			Integer googlers = Integer.valueOf(datos[0]);
			Integer sospechosos = Integer.valueOf(datos[1]);
			Integer p = Integer.valueOf(datos[2]);
			Integer puntuacion;
			Integer personas = 0;
			ArrayList<Integer> puntuaciones = new ArrayList<Integer>();
			for(int j=0;j<googlers;j++){
				puntuacion = Integer.valueOf(datos[3+j]);
				puntuaciones.add(puntuacion);
			}
			Integer[] pOrdenado = null;
			pOrdenado = (Integer[]) puntuaciones.toArray(new Integer[puntuaciones.size()]);
			Arrays.sort(pOrdenado);
			int j;
			for(j=pOrdenado.length-1;j>=0;j--){
				if(pOrdenado[j] >= p*3-2){
					personas += 1;
				}else{
					break;
				}
			}
			int posibles = j+1-sospechosos;
			for(;j>=posibles && j>= 0;j--){
				if(pOrdenado[j] >= p*3-4 && pOrdenado[j] > p){
					personas += 1;
				}else{
					break;
				}
			}
			System.out.println("Case #"+i+": "+personas);
		}
	}

}

package google.code.jam;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.ListIterator;

public class DancingWithTheGooglers {

	final static String fileNameIn = "B-large.in";
	final static String fileNameOut = "B-large.out";

	private static int solve(int S, int p, List<Integer> t) {
		int count = 0;
		for (int i = 0; i < t.size(); i++) {
			int bestResultNotSurprising = getBestResultNotSurprising(t.get(i));
			int bestResultSurprising = getBestResultSurprising(t.get(i));
			if (bestResultNotSurprising >= p) {
				count++;
			} else if (bestResultSurprising >= p && S > 0) {
				count++;
				S--;
			}
		}
		return count;
	}

	private static int getBestResultNotSurprising(int n) {
		return getBestResult(n, false);
	}

	private static int getBestResultSurprising(int n) {
		return getBestResult(n, true);
	}

	private static int getBestResult(int n, boolean surprising) {
		int average = (int) Math.floor(n / 3);
		int residue = n % 3;
		if (n == 0)
			return 0;
		if (surprising && residue == 0)
			return average + 1;
		if (surprising && residue == 1)
			return average + 1;
		if (surprising && residue == 2)
			return average + 2;
		if (!surprising && residue == 0)
			return average;
		if (!surprising && residue == 1)
			return average + 1;
		if (!surprising && residue == 2)
			return average + 1;
		return average;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new FileReader(fileNameIn));
		BufferedWriter out = new BufferedWriter(new FileWriter(fileNameOut));
		int testCases = Integer.parseInt(in.readLine());
		for (int i = 0; i < testCases; i++) {
			String[] elements = in.readLine().split(
					new Character((char) 32).toString());
			List<Integer> values = new ArrayList<Integer>();
			for (String v : elements) {
				values.add(Integer.valueOf(v));
			}
			ListIterator<Integer> iterator = values.listIterator();
			int N = iterator.next();
			int S = iterator.next();
			int p = iterator.next();
			List<Integer> t = values.subList(values.size() - N, values.size());
			out.write(String.format("Case #%s: %s\n", i + 1, solve(S, p, t)));
		}
		in.close();
		out.close();
	}

}
