import java.util.List;


public class Case implements Runnable {

	private int id;
	private String output;

	private int n;
	private int s;
	private int p;
	private List<Integer> g;

	public Case(int id) {
		this.id = id;
	}

	public Case(int id, int n, int s, int p, List<Integer> g) {
		super();
		this.id = id;
		this.n = n;
		this.s = s;
		this.p = p;
		this.g = g;
	}

	public String solve() {
		int res = 0;
		for (int googler : g) {
			int b = googler / 3;
			boolean div = googler % 3 == 0;
			if (b >= p) {
				res++;
				continue;
			}
			if (p == b+1) {
				if (div && s > 0 && b > 0) {
					res++;
					s--;
					continue;
				}
				if (!div) {
					res++;
					continue;
				}
			}
			if (p == b+2) {
				if (3*b+2 == googler && s > 0) {
					res++;
					s--;
				}
			}
		}
		return String.valueOf(res);
	}

	@Override
	public void run() {
		output = solve();
	}

	@Override
	public String toString() {
		return "Case #" + id + ": " + output;
	}

}

import java.io.*;
import java.util.*;

public class CodeJam2012_Q_B {

	public int calc(int N, int S, int p, int[] score) {
		int cnt=0;
		for(int i=0; i<N; i++) {
			if(score[i] >= p+Math.max(p-1, 0)*2) {
				cnt++;
			} else if(score[i]>=p+Math.max(p-2, 0)*2 && S>0) {
				cnt++;
				S--;
			}
		}
		
		return cnt;
	}
	
	public static void main(String[] args) {
		try{
			(new CodeJam2012_Q_B()).exec("2012_Q_B-small.in", "2012_Q_B-small.out");
			}catch(Exception ex) {
				
			}
	}

	public final void exec(String inFileName, String outFileName) throws Exception{
		BufferedReader	inReader	= new BufferedReader(new FileReader(inFileName));
		PrintWriter		outWriter	= new PrintWriter(new BufferedWriter(new FileWriter(outFileName)));
		int caseNums=0;
		caseNums = Integer.parseInt(inReader.readLine());
		
		for(int i=0; i<caseNums; i++) {
			String[] input = inReader.readLine().split(" ");
			int N = Integer.valueOf(input[0]);
			int S = Integer.valueOf(input[1]);
			int p = Integer.valueOf(input[2]);
			int[] score = new int[N];
			for(int j=0; j<N; j++)
				score[j] = Integer.valueOf(input[j+3]);
			int outStr = calc(N, S, p, score);

			String fmtOutStr="Case #" + (i+1) + ": " + outStr;	
			outWriter.println(fmtOutStr);
			System.out.println(fmtOutStr);
		}
		System.out.println(caseNums + " cases complete");

		outWriter.close();
		inReader.close();
	}
}
