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;
   }
}
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;

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

/**
 *
 * @author ZIYAN
 */
public class Codejam2 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws FileNotFoundException, IOException {
        
        
       
         Scanner scanner = new Scanner(new File("C:\\Documents and Settings\\ZIYAN\\Desktop\\B-small-attempt2.IN"));
       
       
        FileWriter fstream = new FileWriter("C:\\Documents and Settings\\ZIYAN\\Desktop\\out.txt");
        BufferedWriter out = new BufferedWriter(fstream);
        
        int cases=scanner.nextInt();
        for(int l=0;l<cases;l++)
        {
            out.write("Case #"+(l+1)+": ");
        int a,b,c;
        a =scanner.nextInt();
        b=scanner.nextInt();
        c=scanner.nextInt();
        
        
        int[] x=new int[a];
        for(int m=0;m<a;m++)
        {
            x[m]=scanner.nextInt();
        }
        if(c==0)
        {
            int reslt=a;
            String rs="";
            rs+=reslt;
            System.out.println(rs);
            out.write(rs);
            out.newLine();
            //continue;
        }
        else{
        int [][] arr=arrngaryy(x);
      
        int reslt=0;
        for(int i=0;i<a;i++)
        {
            
            int add=arr[i][0]+arr[i][1]+arr[i][2];
            if(add==0)
            {
                continue;
            }
            if(add>=(3*c-2))
            {
                reslt++;
            }
            else if(add<=(3*(c-1))&& add>=(3*c-4) && b!=0 )
            {
                reslt++;
                b--;
            }
        }
        String rs="";
        rs+=reslt;
        System.out.println(rs);
        out.write(rs);
         out.newLine();
        
        }
        }
        out.close();
        
        
        
        
        
      
        
        
        
    }
    
    public static int[][] arrngaryy(int[] x)
    {
        int a=x.length;
        int[][] arr=new int[a][3];
        for(int i=0;i<a;i++)
        {
            
            if(x[i]%3==2)
            {
                arr[i][0]=x[i]/3;
                arr[i][1]=x[i]/3+1;
                arr[i][2]=x[i]/3+1;
                
            }
            else if(x[i]%3==1)
            {
                arr[i][0]=x[i]/3;
                arr[i][1]=x[i]/3;
                arr[i][2]=x[i]/3+1;
            }
            else
            {
                arr[i][0]=x[i]/3;
                arr[i][1]=x[i]/3;
                arr[i][2]=x[i]/3;
            }
        }
        return arr;
    }
}
