package problem1;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;





public class Problem1 {

    public static void main(String[] args) throws FileNotFoundException, IOException{
        try {
             TextIO.readFile("L:\\Coodejam\\Input\\Input.txt");
        }
        catch (IllegalArgumentException e) {
              System.out.println("Can't open file ");
              System.exit(0);
         }
        
        FileOutputStream fout = new FileOutputStream("L:\\Coodejam\\Output\\output.txt");
        PrintStream ps=new PrintStream(fout);
        
        int cases=TextIO.getInt();
        int googlers=0,surprising=0,least=0;
        for(int i=0;i<cases;i++){
            int counter=0;
            googlers=TextIO.getInt();
            surprising=TextIO.getInt();
            least=TextIO.getInt();
            int score[]=new int[googlers];
            for(int j=0;j<googlers;j++){
                score[j]=TextIO.getInt();
                 }
            
            
            
            
            Arrays.sort(score);
            int temp=0;
            int sup[]=new int[surprising];
            
          for(int j=0;j<googlers && surprising>0;j++){
               if(biggestNS(score[j])<least && biggestS(score[j])==least){
                   surprising--;
                   counter++;
                }
               }
           
            for(int j=0;j<googlers;j++){
                if(surprising==0)temp=biggestNS(score[j]);
                    
                else {
                    temp=biggestS(score[j]);
                    surprising--;     
                } 
                   if(temp>=least)counter++;
           
             }
            
             ps.println("Case #"+(i+1)+": "+counter);
        }
    }
    
   static int biggestNS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-1)/3)+1;
   }
   
   static int biggestS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-2)/3)+2;
   }
}
/**
 * 
 * @author luoyuan
 *
 */
package codejam;

import java.util.ArrayList;
import static java.lang.Math.*;

public class Dancing {

	public static void bestResult(String inF,String outF) {
		InOutTool iot = new InOutTool(inF,outF);
		ArrayList<String> js = new ArrayList<String>();
		for(int i=1;i<iot.size();i++){
			String in = iot.get(i).trim();
			String[] num = in.split(" ");
			int n = Integer.parseInt(num[0]), s = Integer.parseInt(num[1]), p = Integer.parseInt(num[2]);
			int sup=0,count=0;
			for(int k=3;k<num.length;k++){
				int i_0=0,i_1=0,i_2=0;
				int temp = Integer.parseInt(num[k]);
				i_0 = temp/3;
				if(i_0>=p){
					count ++;
				}else{
					if(i_0<(p-2)||(temp-i_0)<p||(temp-i_0)>(2*p+2)||(temp-i_0)<(2*p-2)){
						//no case want
					}else{//maybe surprising cases
						i_1 = p; i_2 = temp - i_0 - i_1;
						count ++;
						if(abs(i_2-i_0)>1||abs(i_2-i_1)>1)sup ++;
					}
				}
			}
			if(sup>s)count -= (sup-s);
			js.add("Case #" + i + ": " + count);
		}
		iot.clear();iot.addAll(js);
		iot.outText();
	}
	public static void main(String...args){
		Dancing.bestResult("B-small-attempt0.in", "B-small-attempt0.out");
	}
}
