/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 3/3/12
 * Time: 11:00 AM
 * To change this template use File | Settings | File Templates.
 */

import SRMLib.MathLibrary;
import SRMLib.TestSRMLib;
import com.sun.org.apache.bcel.internal.generic.F2D;

import java.io.*;
import java.util.*;
import java.util.zip.Inflater;

public class SRM {
    public static void main(String[] args) throws IOException {
        //TestSRMLib.run();
        codeJam1.main();

        return;
    }
}
class codeJam1 {
    public static void main() throws IOException {
        String inputPath = "E:\\input.txt";
        String outputPath = "E:\\output.txt";
        BufferedReader input = new BufferedReader(new FileReader(inputPath));
        BufferedWriter output = new BufferedWriter(new FileWriter(outputPath));

        String line;
        line = input.readLine();
        int T = Integer.parseInt(line);
        for (int i = 1; i <= T; ++i) {
            line = input.readLine();
            String[] words = line.split(" ");
            int N = Integer.parseInt(words[0]);
            int S = Integer.parseInt(words[1]);
            int p = Integer.parseInt(words[2]);
            int n = 0;
            int res = 0;

            for (int j = 3; j < words.length; ++j) {
                if (p == 0) {
                    res++;
                    continue;
                }

                int t = Integer.parseInt(words[j]);
                if (p == 1) {
                    if (t > 0)
                        res++;
                    continue;
                }
                if (t >= 3 * p - 2)
                    res++;
                else if (t >= 3 * p - 4)
                    n++;
            }

            res += Math.min(n, S);
            output.write("Case #" + i + ": " + res);
            output.newLine();
        }

        input.close();
        output.close();
    }
}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;


public class Dancing {
	public static void main(String[] args){
		List<String> input=new ArrayList<String>();
		List<String> output=new ArrayList<String>();
		try{
			  // Open the file that is the first 
			  // command line parameter
			  FileInputStream fstream = new FileInputStream("c:/input/B-small-attempt0.in");
			  // Get the object of DataInputStream
			  DataInputStream in = new DataInputStream(fstream);
			  BufferedReader br = new BufferedReader(new InputStreamReader(in));
			  String strLine;
			  //Read File Line By Line
			  while ((strLine = br.readLine()) != null)   {
			  // Print the content on the console
			  input.add(strLine);
			  }
			  //Close the input stream
			  in.close();
			    }catch (Exception e){//Catch exception if any
			  System.err.println("Error: " + e.getMessage());
			  }
		/*input done*/
		for(int j=1;j<input.size();j++){
			String a=input.get(j);
			//System.out.println("getting input as"+a);
			String b[]=a.split(" ");
			int n,s,p,t[]=null;
			n=Integer.parseInt(b[0]);
			s=Integer.parseInt(b[1]);
			p=Integer.parseInt(b[2]);
			t=new int[n];
			for(int i=3;i<b.length;i++){
				t[i-3]=Integer.parseInt(b[i]);
			}
			int count=0,div,mod;
			for(int i=0;i<t.length;i++){
				div=t[i]/3;
				mod=t[i]%3;
				if(div>=p){
					count++;
					//System.out.println("normal"+t[i]);
				}else if((div+Math.min(mod,1)>=p)){
					count++;
					//System.out.println("with increment"+t[i]);
				}else if((div+Math.min(mod,2)>=p)&&(s>0)){
					count++;
					if(mod>=2){
						s--;
						//System.out.println("surprised"+t[i]+"remaining s"+s);
					}
				}else if((div+1>=p)&&(div>0)&&(s>0)){
					count++;
					s--;
					//System.out.println("superficial"+t[i]);	
				}else{
					//System.out.println("noting happened"+t[i]+" div is "+div+"mod is"+mod);
				}
			}
			output.add(count+"");
			/*counting done*/
			//System.out.println(count);
		}
		try {
            BufferedWriter bw = new BufferedWriter(new FileWriter(new File("C:/output/Dancing.out"), true));
            for(int i=0;i<output.size();i++){
            	bw.write("Case #"+(i+1)+": "+output.get(i));
            	bw.newLine();
            }
            bw.close();
		} catch (Exception e) {
			System.err.println("Error: " + e.getMessage());
		}
		
	}

}
