import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;


public class Dancing {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// read input file
		File file = new File("B-small-attempt4.in");
		//File file = new File("input.txt");
		BufferedReader br = new BufferedReader(new FileReader(file));
		String ln = "";
		int count = Integer.parseInt(br.readLine());

		// write output file
		File out = new File("outB.txt");
		BufferedWriter bw = new BufferedWriter(new FileWriter(out));
		
		int y = 0;
		for (int i=0; i < count; i++){
			ln = br.readLine();
			y = getY(ln);
			bw.write("Case #" + (i+1) + ": " + y);
			bw.newLine();
		}
		bw.close();
	}
	
	private static int getY(String str) {
		String[] data = str.split(" ");
		int n = Integer.parseInt(data[0]);
		int s = Integer.parseInt(data[1]);
		int p = Integer.parseInt(data[2]);
		int[] t = new int[n];
		for (int i=0; i < n; i++){
			t[i] = Integer.parseInt(data[i+3]);
		}
		int y = 0;
		int base = 0;
		for(int j=0; j < t.length; j++){
			base = t[j] / 3;
			if(base >= p) { y++; }
			else if(base == p-1){
				if(t[j] - (base+p) > base-1 && t[j] > 0){
					y++;
				} else if(s>0 && t[j] - (base+p) > base-2 && t[j] > 0){
					s -= 1;
					y++;
				}
			} else if(base == p-2){
				if(s > 0 && t[j] - (base+p) > base-1 && t[j] > 0){
					s -= 1;
					y++;
				}
			}
		}
		
		return y;
	}

}

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);
	}
}
