/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Dancing
 * Jason Bradley Nel
 * 16287398
 */
import java.io.*;

public class Dancing {

    public static void main(String[] args) {

        In input = new In("input.txt");
        int T = Integer.parseInt(input.readLine());

        for (int i = 0; i < T; i++) {
            System.out.printf("Case #%d: ", i + 1);
            int N = input.readInt();
            int s = input.readInt();
            int p = input.readInt();
            int c = 0;//counter for >=p cases
            //System.out.printf("N: %d, S: %d, P: %d, R: ", N, s, p);
            
            for (int j = 0; j < N; j++) {
                
                int score = input.readInt();
                int q = score / 3;
                int m = score % 3;
                //System.out.printf("%2d (%d, %d) ", scores[j], q, m);
                                
                switch (m) {
                    case 0:
                        if (q >= p) {
                            c++;
                        } else if (((q + 1) == p) && (s > 0) && (q != 0)) {
                            c++;
                            s--;
                        }
                        break;
                    case 1:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        }
                        break;
                    case 2:
                        if (q >= p) {
                            c++;
                        } else if ((q + 1) == p) {
                            c++;
                        } else if (((q + 2) == p) && (s > 0)) {
                            c++;
                            s--;
                        }
                        break;
                }
            }
            //System.out.printf("Best result of %d or higher: ", p);
            System.out.println(c);
        }


    }
}

package ponder.CodeJamQualify;

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

/**
 * @author: sg  Date: 15.04.12
 */
public class TaskB
{
	static int calc(final int p, final int strangeOrig, final int[] marks)
	{
		int cnt = 0;
		int strange = strangeOrig;
		for (int total : marks)
		{
			int max = total / 3;
			if ((total % 3) != 0)
				max += 1;

			if (max >= p)
			{
				cnt++;
				continue;
			}

			if (total <= 1)
				continue;

			if (((total % 3) != 1) && (strange > 0) && (max == p - 1))
			{
				cnt++;
				strange--;
			}
		}
		return cnt;
	}

	public static void main(String[] args) throws IOException
	{
		final long start = System.currentTimeMillis();

//		PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("taskB.out")));
//		BufferedReader reader = new BufferedReader(new FileReader("taskB.in"));

		PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter("B-small-attempt0.out")));
		BufferedReader reader = new BufferedReader(new FileReader("B-small-attempt0.in"));

		String inLine;
		int caseIndex = 0;
		inLine = reader.readLine();
		while (null != (inLine = reader.readLine()))
		{
			StringTokenizer st = new StringTokenizer(inLine);
			final int n = Integer.parseInt(st.nextToken());
			final int s = Integer.parseInt(st.nextToken());
			final int p = Integer.parseInt(st.nextToken());
			int[] marks = new int[n];
			for (int i = 0; i < n; i++)
				marks[i] = Integer.parseInt(st.nextToken());
			caseIndex++;
			int cnt = calc(p, s, marks);
			writer.printf("Case #%d: %d\r\n", caseIndex, cnt);
		}

		writer.close();


		final long finish = System.currentTimeMillis();
		final long dur = finish - start;
		System.err.println(dur);
	}
}
