/**
 * 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.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.Scanner;

public class DancingWiththeGooglers {
	final static String FILENAME = "B-small-attempt0";

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new FileReader("/home/workshop/Documents/"
				+ FILENAME + ".in"));
		BufferedWriter bw = new BufferedWriter(new FileWriter(
				"/home/workshop/Documents/" + FILENAME + ".out"));
		int T = sc.nextInt();
		sc.nextLine();
		for (int ttt = 0; ttt < T; ttt++) {
			int N = sc.nextInt();
			int S = sc.nextInt();
			int p = sc.nextInt();

			int s = S, count = 0;
			for (int n = 0; n < N; n++) {
				int t = sc.nextInt();
				switch (t % 3) {
				case 0:
					int z = t / 3; // z, z, z
					if (z >= p)
						count++;
					else if (s > 0 && z + 1 >= p && z - 1 >= 0 && z + 1 <= 10) {
						// z-1, z, z+1 (*)
						count++;
						s--;
					}
					break;
				case 1:
					int x = (t - 1) / 3; // x, x, x+1
					if (x + 1 >= p)
						count++;
					break;
				case 2:
					int y = (t - 2) / 3; // y, y+1, y+1
					if (y + 1 >= p)
						count++;
					else if (s > 0 && y + 2 >= p && y + 2 <= 10) {
						// y, y, y+2 (*)
						count++;
						s--;
					}
					break;
				}
			}

			bw.write("Case #" + (ttt + 1) + ": " + count);
			bw.newLine();
		}
		bw.close();
		sc.close();
	}

}
