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

import java.io.*;

public class Dance_Comp {
    int N,count=0;
    String s="",temp[];
    public Dance_Comp() {
        try {
            FileInputStream fis=new FileInputStream("B-small-attempt0.in");
            DataInputStream dis=new DataInputStream(fis);
            FileOutputStream fos = new FileOutputStream("B-small-attempt0.out");
            DataOutputStream dos=new DataOutputStream(fos);
            N=Integer.parseInt(dis.readLine());
            for(int i=1;i<=N;i++)
            {
                s=dis.readLine();
                count=0;
                temp=s.split(" ");
                int dancer=Integer.valueOf(temp[0]),surp=Integer.valueOf(temp[1]),cut_of=Integer.valueOf(temp[2]);
                int mrk;
                for(int j=0;j<dancer;j++)
                {
                    mrk=Integer.valueOf(temp[3+j]);
                    int r=mrk%3;
                    mrk=mrk/3;
                    if(mrk>=cut_of || (mrk==(cut_of-1) && r>0))
                    {
                        count++;
                    }
                    else if(surp>0 && ((mrk==(cut_of-2) && r==2) || (mrk==(cut_of-1) && mrk>0)))
                    {
                        count++;
                        surp--;
                    }
                }
                
                s="Case #"+i+": "+count;
                if(i!=N)
                {
                    s=s+"\n";
                }
//                System.out.println(s);
                dos.writeBytes(s);
            }
            fis.close();
            fos.close();
            }catch(Exception e){
                System.out.println("Error: "+e);
            }
    }

    public static void main(String[] args) {
        new Dance_Comp();
    }
}
