/**
 * 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.util.*;
import java.io.*;
public class CodeJam2{
public static HashMap<Integer,Vector<Integer>> perm = new HashMap<Integer,Vector<Integer>>();
public static void main(String args[]) throws IOException{
llenar();
BufferedReader lector = new BufferedReader(new FileReader(args[0]));
String tmp = lector.readLine();
int uu = 1;
while((tmp = lector.readLine())!=null){
String tar[] = tmp.split(" ");
int sorpr = Integer.parseInt(tar[1]),r = 1<<Integer.parseInt(tar[0]);
int cond = Integer.parseInt(tar[2]);
int max =0;
for(int n = 0;n<=r;n++){
int tmpMax = 0;
int cont = 0,contt=0,mm=n;
do{
if((mm&1)==1)
cont++;
if(sat(Integer.parseInt(tar[3+contt]),cond,mm&1))tmpMax++;
contt++;
}while((mm>>=1)>0 && contt<Integer.parseInt(tar[0]));
if(cont!=sorpr)continue;
for(int u = contt;u<Integer.parseInt(tar[0]);u++)
if(sat(Integer.parseInt(tar[3+u]),cond,0))tmpMax++;
max = Math.max(tmpMax,max);
}
System.out.println("Case #"+(uu++)+": "+max);
}

}
public static boolean sat(int num,int cond,int r){
Vector<Integer> tmpp = perm.get(num);
return tmpp.get(r*3+2)>=cond;
}
public static void llenar(){//0 no sat, 1 sat

for(int n = 0;n<31;n++){
int tmpMaxx[][] = new int[2][3];
for(int nn = 0;nn<=n;nn++)
for(int nnn = 0;nnn<=nn;nnn++)
for(int nnnn =0;nnnn<=nnn;nnnn++)
if((nn-nnnn)<=2 && ((nn+nnn+nnnn)==n)){
if((nn-nnnn)==2 && nn>tmpMaxx[1][2]){
tmpMaxx[1][0]=nnnn;
tmpMaxx[1][1]=nnn;
tmpMaxx[1][2]=nn;
}else if((nn-nnnn)!=2 && nn>tmpMaxx[0][2]){
tmpMaxx[0][0]=nnnn;
tmpMaxx[0][1]=nnn;
tmpMaxx[0][2]=nn;
}

}
Vector<Integer> rejoder = new Vector<Integer>();
for(int k =0;k<tmpMaxx.length;k++)
for(int kk = 0;kk<tmpMaxx[k].length;kk++)
rejoder.add(tmpMaxx[k][kk]);
perm.put(n,rejoder);
//System.out.println(n+" "+rejoder);
}

}
}
