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

import java.io.*;

public class DancingWithTheGooglers {

    private BufferedReader br;
    private BufferedWriter wr;
    
    public DancingWithTheGooglers(String filein,String fileout){
        try{
            br = new BufferedReader(new 
                    InputStreamReader(new FileInputStream(filein)));
            wr = new BufferedWriter(new FileWriter(fileout));
            
            int num = 0;
            num = Integer.parseInt(br.readLine());
            
            for (int i = 1;i<=num;i++){
                String buf = br.readLine();
                String[] bufarray = buf.split(" ");
                int n = Integer.parseInt(bufarray[0]);
                int s = Integer.parseInt(bufarray[1]);
                int p = Integer.parseInt(bufarray[2]);
                int numgood = 0;
                for (int j = 3;j<bufarray.length;j++){
                    int now = Integer.parseInt(bufarray[j]);
                    
                    int div = now/3;
                    int mod = now%3;
                    
                    switch(mod){
                        case 0:
                            if (div >= p){
                                numgood++;
                            }else if (s > 0 && div > 0 && div+1 >= p){
                                numgood++;
                                s--;
                            }
                            break;
                        case 1:
                            if (div >= p || div+1 >= p){
                                numgood++;
                            }
                            break;
                        case 2:
                            if (div >= p || div+1 >= p){
                                numgood++;
                            }else if (s > 0 && div+2 >= p){
                                numgood++;
                                s--;
                            }
                            break;
                    }
                }
                String out = "Case #"+i+": "+numgood;
                wr.write(out);
                if (i != num)
                    wr.newLine();
            }
            
            br.close();
            wr.close();
        }catch (IOException e){
            System.out.println("IO failure");
        }
    }
    
    public static void main(String[] args) {
        DancingWithTheGooglers sp = new DancingWithTheGooglers("B-large.in","B-large.out");
    }
}
