import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

public class b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));

        int T = sc.nextInt();

        for (int casenumber = 1; casenumber <= T; ++casenumber) {

            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();

            int[] ts = new int[n];
            for (int i = 0; i < n; ++i)
                ts[i] = sc.nextInt();

            int thresh1 = (p == 1 ? 1 : (3 * p - 4));
            int thresh2 = (3 * p - 2);

            int count1 = 0, count2 = 0;

            for (int i = 0; i < n; ++i) {
                if (ts[i] >= thresh2) {
                    ++count2;
                    continue;
                }
                if (ts[i] >= thresh1) {
                    ++count1;
                }
            }

            if (count1 > s) {
                count1 = s;
            }

            System.out.format("Case #%d: %d%n", casenumber, count1 + count2);
        }
    }
}

package dancingwiththegooglers;

import java.util.Arrays;

import template.Template;

public class DancingWithTheGooglers extends Template {
	public static void main(String[] args) throws Exception {

		init("src/dancingwiththegooglers/B-small-attempt3");
		int lines = readInt();
		for (int i = 1; i <= lines; i++) {
			int[] line = readIntArray();
			int n = line[0];
			int s = line[1];
			int p = line[2];
			int[] t = new int[n];
			int result = 0;
			for (int j = 0; j < n; j++) {
				t[j] = line[j + 3];
				int m = t[j] / 3;
				int r = t[j] % 3 > 0 ? 1 : 0;
				if (m >= p)
					result++;
				else if (m + r >= p
						&& (m - r >= 0 || m + r > 0 && t[j] % 3 == 2))
					result++;
				else if (m + r + 1 >= p && s > 0 && m - r - 1 >= 0
						&& t[j] % 3 != 1) {
					result++;
					s--;
				}

			}

			System.out.println("\n" + Arrays.toString(line));
			write("Case #" + i + ": " + result);
		}
	}
}
