import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

public class b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));

        int T = sc.nextInt();

        for (int casenumber = 1; casenumber <= T; ++casenumber) {

            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();

            int[] ts = new int[n];
            for (int i = 0; i < n; ++i)
                ts[i] = sc.nextInt();

            int thresh1 = (p == 1 ? 1 : (3 * p - 4));
            int thresh2 = (3 * p - 2);

            int count1 = 0, count2 = 0;

            for (int i = 0; i < n; ++i) {
                if (ts[i] >= thresh2) {
                    ++count2;
                    continue;
                }
                if (ts[i] >= thresh1) {
                    ++count1;
                }
            }

            if (count1 > s) {
                count1 = s;
            }

            System.out.format("Case #%d: %d%n", casenumber, count1 + count2);
        }
    }
}

package B;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class B {
	public static void main(String[] args) throws IOException {
		Scanner sc;
		try {
			sc = new Scanner(new File("B"));
			FileWriter writer = null;
			try {
				writer = new FileWriter(new File("output"));
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
			int nbLines = Integer.parseInt(sc.nextLine());
			int currentLine = 1;
			
			int nbGooglers;
			int surprising;
			int p;
			String line ="";
			
			int currentGoogler;
			
			int g;
			
			int quotient;
			int reste;
			
			int res;
			while (currentLine <= nbLines) {
				writer.write("Case #"+currentLine+": ");
				res=0;
				currentGoogler = 1;
				line = sc.nextLine();
				Scanner scan = new Scanner(line);
				nbGooglers=scan.nextInt();
				surprising = scan.nextInt();
				p=scan.nextInt();
				while (currentGoogler <= nbGooglers) {
					g = scan.nextInt();
					quotient = g/3;
					reste = g % 3;
					System.out.println(g + " " +quotient + " " + p);
					if (g == 0 && p > 0)
						;
					else if (quotient >= p)
						res++;
					else {
						if ((quotient == (p - 1)) && (reste >= 1))
							res++;
						else if (quotient == (p - 2) && (reste == 2) && (surprising != 0)) {
							surprising --;
							res++;
						}
						else if (quotient == (p - 1) && (reste == 0) && (surprising != 0)) {
							surprising --;
							res++;
						}
							
					}
					currentGoogler++;
				}
				writer.write(res + "\n");
				currentLine++;
			}
			writer.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
