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.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class CodeJam2012Ex2Small {

	public static void main(String arg[]) throws FileNotFoundException {
		File file = new File("B-small-attempt0.in");
		Scanner scanner = new Scanner(file);
		String output;
		int numTestCases = scanner.nextInt();
		for (int i = 0; i < numTestCases; i++) {
			StringBuffer buffer = new StringBuffer("Case #" + (i + 1) + ": ");
			int N = scanner.nextInt();
			int S = scanner.nextInt();
			int p = scanner.nextInt();
			int[] googlersPoints = new int[N];
			int bestResults = 0;
			for (int j = 0; j < N; j++) {
				googlersPoints[j] = scanner.nextInt();
				if ((googlersPoints[j] >= (p * 3 - 2))){
					bestResults++;

				} else if ((googlersPoints[j] >= (p * 3 - 4))
						 && S > 0 && googlersPoints[j] != 0) {
					
					bestResults++;
					S--;
				}
			}
			buffer.append(bestResults);
			if (i != numTestCases - 1) {
				buffer.append("\n");
			}
			output = buffer.toString();

			System.out.print(output);
		}

	}
}
