package dancinggooglers;

import java.io.File;
import java.util.Scanner;

public class DanceScoreCalculator {


    public static void main(String[] args) {
        if(args.length <= 0 || args[0] == null) {
            System.out.println("You must enter a file to read");
            System.out.println("Usage: blah <filename>");
            System.exit(0);
        }

        File argFile = new File(args[0]);
        try {
            Scanner googleSpeakScanner = new Scanner(argFile);
            String firstLine = googleSpeakScanner.nextLine();
            Integer linesToScan = new Integer(firstLine);
            for(int i = 1; i <= linesToScan; i++) {
                String googleDancerLine = googleSpeakScanner.nextLine();
                DanceScoreCase danceCase = new DanceScoreCase(googleDancerLine);
                System.out.println(String.format("Case #%d: %d", i, danceCase.maxDancersThatCouldPass()));
            }
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}


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

public class Dancers
{
	public static void main(String[] args)
	{
		try
		{
			Scanner s = new Scanner(new File("dancers.in"));
			BufferedWriter w = new BufferedWriter(new FileWriter(new File("dancers.out")));
			int numCases = s.nextInt();
			s.nextLine();
			
			for(int n = 1;n <= numCases; n++)
			{
				int numGooglers = s.nextInt();
				int surprising = s.nextInt();
				int p = s.nextInt();
				int lowerBoundWithoutSurprising = (p * 3) - 2;
				int lowerBoundWithSurprising = (p * 3) - 4;
				
				if(lowerBoundWithoutSurprising < p)
					lowerBoundWithoutSurprising = p;
				if(lowerBoundWithSurprising < p)
					lowerBoundWithSurprising = p;
				
				int count = 0;
				for(int m = 1; m <= numGooglers; m++)
				{
					int cur = s.nextInt();

					if(cur >= lowerBoundWithoutSurprising)
						count++;
					else if(cur >= lowerBoundWithSurprising && surprising > 0)
					{
						count++;
						surprising--;
					}
				}
				w.write("Case #" + n + ": " + count + "\n");
			}
			
			w.flush();
			w.close();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}
	}
	

}