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.util.HashMap;
import java.util.Scanner;

public class DanceScores {

	public static void main(String[] args) {
		HashMap<Integer,int[]> best = new HashMap<Integer, int[]>();
		best.put(1 , new int[]{1,1});
		best.put(2 , new int[]{2,3});
		best.put(3 , new int[]{4,6});
		best.put(4 , new int[]{7,9});
		best.put(5 , new int[]{10,12});
		best.put(6 , new int[]{13,15});
		best.put(7 , new int[]{16,18});
		best.put(8 , new int[]{19,21});
		best.put(9 , new int[]{22,24});
		best.put(10, new int[]{25,27});
		
		Scanner in = new Scanner(System.in);
		int cases = in.nextInt();
		for(int i=1; i<=cases; i++){
			int n = in.nextInt();	//Number of scores
			int s = in.nextInt();	//Number of surprising score triplets
			int p = in.nextInt();	//The minimum criterion

			/********* Boundary Cases ********/
			if(p==0){
				System.out.println("Case #"+i+": "+n);
				in.nextLine(); //Ignore remaining line
				continue;
			}
			
			int[] range = best.get(p);	//The range where the best score p can be achieved only in case of surprising triplet.
			int definite = 0, probable=0;

			for(int j=0;j<n;j++){
				int score = in.nextInt();	//Reading individual scores
				if(score>=range[0] && score <=range[1])
					probable++;
				else if(score>range[1])
					definite++;
			}
			System.out.println("Case #"+i+": "+(definite+Math.min(probable, s)));
		}
	}

}
