/**
 * 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.*;
import java.util.*;

public class B{
	public static ArrayList<Case> cases = new ArrayList<Case>();
	public static void main (String [] args){
		
		parseFile();
		for(int i=0; i<cases.size(); i++){
			//System.out.print(cases.get(i).n +" ");
			//System.out.print(cases.get(i).s +" ");
			//System.out.print(cases.get(i).p +" ");
			//for(int j=0; j< cases.get(i).totals.size(); j++){
				//System.out.print(cases.get(i).totals.get(j) + " ");
			//}
			System.out.println("Case #" +(i+1)+": " + play(cases.get(i)));
		}
		
	}
	
	static void parseFile(){
		BufferedReader br = null;
		try{
			br = new BufferedReader(new FileReader("b-small.in"));
			int caseCnt = Integer.parseInt(br.readLine());
			ArrayList<String> al = null;
			StringTokenizer st = null;
			
			for(int i=0; i<caseCnt; i++){
				al = new ArrayList<String>();
				st = new StringTokenizer(br.readLine());
				while (st.hasMoreTokens()) {
					al.add(st.nextToken());
				}
				
				Case c = new Case();
				c.n = Integer.parseInt(al.get(0));
				c.s = Integer.parseInt(al.get(1));
				c.p = Integer.parseInt(al.get(2));				
				for(int j=3; j<al.size(); j++){
					c.totals.add(al.get(j));
				}
				cases.add(c);
			}
		}catch(IOException ioe){
			try{br.close();}catch(Exception e){}
		}
	}
	
	static int play(Case c){
		int nLimit = c.p *3 - 2;
		if(nLimit < 0){nLimit = 0;}

		int ans = 0;
		//System.out.println("nLimit="+nLimit);
		for(int i=0; i<c.totals.size(); i++){
			int total = Integer.parseInt(c.totals.get(i));
			if (c.p ==0){ans ++; continue;}
			if (c.p >0 && total == 0){continue;}
			if(c.p ==1 && total>0){ans ++; continue;}
			//System.out.println("total="+total);
			if(total>= nLimit){
				ans ++;
			}else if((total == (nLimit-1))||(total == (nLimit-2))){
				if (c.s <=0){
				}else{
					ans ++;
					c.s --;
				}
			}
		}
		return ans;
	}
	
	static class Case{
		int n;
		int s;
		int p;
		ArrayList<String> totals = new ArrayList <String>();
	}
} 
