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

public class ProblemSample implements Problem {

    private int solution;

    private int googlers;

    private int surprises;

    private int note;

    private List<Integer> sums = new ArrayList<Integer>();

    @Override
    public void solve() {

        int resultat = 0;

        for (int i = 0; i < sums.size(); i++) {

            if (note == 0) {
                // Ils ont tous eu au moins 0...
                resultat = this.googlers;
            } else if (note == 1) {
                // Tous ceux qui ont eu au moins 1 ont eu au moins la note de 1.
                if (sums.get(i) >= 1) {
                    resultat++;
                }
            } else {
                if ((sums.get(i) == 3 * note - 4 || sums.get(i) == 3 * note - 3) && sums.get(i) > note) {
                    // S'ils sont tout juste, ils ont utilisÃ© une surprise.
                    surprises--;
                    // Et on les compte que si il restait des surprises Ã  consommer
                    if (surprises >= 0) {
                        resultat++;
                    }
                }
                if (sums.get(i) >= 3 * note - 2 && sums.get(i) > note) {
                    // Ok sans surprise.
                    resultat++;
                }
            }
        }
        this.setSolution(resultat);
    }

    @Override
    public void print() {
        System.out.println(googlers + " " + surprises + " " + note + " " + sums.toString());
    }

    @Override
    public Object getSolution() {
        return solution;
    }

    public void setSolution(int solution) {
        this.solution = solution;
    }

    public int getGooglers() {
        return googlers;
    }

    public int getSurprises() {
        return surprises;
    }

    public int getNote() {
        return note;
    }

    public List<Integer> getSums() {
        return sums;
    }

    public void setGooglers(int googlers) {
        this.googlers = googlers;
    }

    public void setSurprises(int surprises) {
        this.surprises = surprises;
    }

    public void setNote(int note) {
        this.note = note;
    }

    public void setSums(List<Integer> sums) {
        this.sums = sums;
    }

}