import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class DancingWithTheGooglers {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader (new FileReader("B-small.in"));
		PrintWriter out = new PrintWriter(new FileWriter("B-small.out"));
		
		int t = Integer.parseInt(f.readLine());
		for (int i = 0; i < t; i++){
			int c = 0;
			StringTokenizer st = new StringTokenizer(f.readLine());
			int n = Integer.parseInt(st.nextToken());
			int[] ti = new int[n];
			int s = Integer.parseInt(st.nextToken());
			int p = Integer.parseInt(st.nextToken());
			for (int j = 0; j < n; j ++){
				ti[j] = Integer.parseInt(st.nextToken());
				if (ti[j] % 3 == 0){
					if (ti[j] / 3 >= p)
						c++;
					else if (ti[j] / 3 == (p-1) && s > 0 && ti[j] >= 2){
						s--;
						c++;
					}
				}
				else if (ti[j] % 3 == 1){
					if ((ti[j] / 3) + 1 >= p)
						c++;					
				}
				else{
					if (ti[j] / 3 >= p-1)
						c++;
					else if (ti[j] / 3 == (p-2) && s > 0){
						s--;
						c++;
					}
				}
					
				
			}
			out.println("Case #" + (i+1) + ": " + c);
			
			
		}
		out.close();
		System.exit(0);
		
		
		
	}
}

package qualification;

import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Scanner;
import java.util.Vector;

public class ProblemB {
	
	static Scanner scan = new Scanner(System.in);
	
	public static void main(String[] args) {

		

		int cases = scan.nextInt();
		
		for ( int i = 1; i <= cases; i++ ) {
			
			System.out.println("Case #" + i + ": " + solveCase());
			
			
		}

	}
	
	public static int solveCase() {
		int numGooglers = scan.nextInt();
		int numSurprising = scan.nextInt();
		int p = scan.nextInt();
		
		Vector<Triplet> containsGreaterThanP = new Vector<Triplet>();
		Vector<Triplet> containsPminus1 = new Vector<Triplet>();
		
		for ( int j = 0; j < numGooglers; j++ ) {
			Triplet t = new Triplet();
			
			int score = scan.nextInt();
			int n = Math.round( score / 3f );
			int n_2 = score - 2*n;
			
			// Ordered triplets
			if ( n_2 > n ) {
				t.add(n_2);
				t.add(n);
				t.add(n);
			} else {
				t.add(n);
				t.add(n);
				t.add(n_2);
			}
			
			if ( t.containsGreaterThan(p) ) {
				// Check if it can be made surprising
				containsGreaterThanP.add(t);
			} else if ( t.contains(p-1) > 1 && p > 1 && t.contains(0) <= 1) {
				containsPminus1.add(t);
			}
		}
//				System.out.println("Googlers: " + numGooglers);
//		System.out.println("Surprising: " + numSurprising);
//		System.out.println("P: " + p);
//		System.out.println(containsGreaterThanP);
//		System.out.println(containsPminus1);
		
		return containsGreaterThanP.size() + Math.min(numSurprising, containsPminus1.size());
		

	}
	
	static class Triplet {
		int[] values = new int[3];
		
		int i = 0;
		
		public void add(int a) {
			if ( i > 2)
				throw new InputMismatchException("Bad input");
			
			values[i] = a;
			i++;
		}
		
		public int contains(int v) {
			
			int retval = 0;
			
			retval += values[0] == v ? 1 : 0;
			retval += values[1] == v ? 1 : 0;
			retval += values[2] == v ? 1 : 0;
			
			return retval;

		}
		
		public boolean containsGreaterThan(int v) {
			// Ordered triplets
			return values[0] >= v;
		}
		
		public boolean allEqual() {
			return values[0] == values[1] && values[1] == values[2];
		}
		
		public String toString() {
			return "(" + values[0] + " " + values[1] + " " + values[2] + ")";
		}
	}
}
