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 example2;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class dance {
    public static void main(String args[]) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int nocases = Integer.parseInt(br.readLine());
        int arr[];
        int ans[] = new int[nocases];
        for (int i = 0; i < nocases; i++) {
            String token[] = br.readLine().split(" ");
            int N = Integer.parseInt(token[0]);
            int S = Integer.parseInt(token[1]);
            int P = Integer.parseInt(token[2]);
            arr=new int[N];
            for (int j = 0; j < N; j++) {
                arr[j] = Integer.parseInt(token[j + 3]);
            }
            ans[i]=method(arr, N, P, S);
        }
        for (int i = 0; i < nocases; i++) {
            System.out.println("Case #" + (i + 1) + ": " + ans[i]);
        }
    }
    private static int method(int[] arr, int N, int P, int S) {
        int c1 = 0, c2 = 0;
        for (int j = 0; j < N; j++) {
            if (arr[j] >= P) {
                int diff = (int) (arr[j] - P);
                if (((2 * P) - diff) <= 2) {
                    c1++;
                } else if ((((2 * P) - diff) <= 4) && (((2 * P) - diff) > 2)) {
                    c2++;
                }
            }
        }
        if (c2 > S) {
            c1 = c1 + S;
        } else {
            c1 = c1 + c2;
        }
        return c1;
    }
}
