import java.util.Scanner;
import java.io.*;
class dance
{
  public static void main (String[] args) throws IOException
  { 
    File    inputData = new File("B-small-attempt0.in");
	File 	outputData= new File("Boutput.txt");
    Scanner scan = new Scanner( inputData );
	PrintStream print= new PrintStream(outputData);
    
	int t;
	int n,s,p,pi;
	t= scan.nextInt();
	for(int i=1;i<=t;i++)
	{
	n=scan.nextInt();	s=scan.nextInt();	p=scan.nextInt();
	int supTrip=0, notsupTrip=0;
	
	for(int j=0;j<n;j++)
	{
		pi=scan.nextInt();
		if(pi>(3*p-3))
		notsupTrip++;
		else if((pi>=(3*p-4))&&(pi<=(3*p-3))&&(pi>p))
		supTrip++;
	}
	
	if(s<=supTrip)
	notsupTrip=notsupTrip+s;
	else if(s>supTrip)
	notsupTrip= notsupTrip+supTrip;
	print.println("Case #"+i+": "+notsupTrip);
	}
  }
}
package problemb;

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

public class DancingWithTheGooglers {

	public static void main(String[] args) {

		int T = 1;
		String G = "";
		String[] inputs;
		BufferedReader reader;

		reader = new BufferedReader(new InputStreamReader(System.in));

		try {
			T = Integer.parseInt(reader.readLine());
		} catch (Exception e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		StringBuffer buffer = new StringBuffer();
		for (int X = 1; X <= T; X++) {
			try {
				G = reader.readLine();
				inputs = G.split(" ");
				int N = Integer.parseInt(inputs[0]);
				int S = Integer.parseInt(inputs[1]);
				int p = Integer.parseInt(inputs[2]);
				int[] t;
				if (inputs.length - 3 > N) {
					t = new int[N];
				} else {
					t = new int[inputs.length - 3];
				}
				for (int i = 0; i < t.length; i++) {
					t[i] = Integer.parseInt(inputs[i + 3]);
				}
				int surprizing = 0;
				Arrays.sort(t);
				int result = 0;
				for (int j = t.length - 1; j >= 0; j--) {
					if(p==0){
						result = t.length;
						break;
					}
					int dev = t[j] / 3;
					int mod = t[j] % 3;
					if (dev >= p) {
						result++;
						continue;
					}
					if (mod == 1 && dev + 1 >= p) {
						result++;
						continue;
					}
					if (mod == 2 && dev + 1 >= p) {
						result++;
						continue;
					}
					if (mod == 2 && dev + 2 >= p && surprizing < S) {
						surprizing++;
						result++;
						continue;
					}
					if (mod == 0 && dev > 0 && dev + 1 >= p && surprizing < S) {
						surprizing++;
						result++;
						continue;
					}
				}

				buffer.append("Case #").append(X).append(": ").append(result)
						.append("\r\n");
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		System.out.println(buffer.toString());
	}

}
