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 dancing;

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

public class DanceAllNight {
	
	
	public static void main(String[] args) throws Exception
	{
		BufferedReader br = new BufferedReader(new FileReader(new File("test.txt")));
		BufferedWriter wr = new BufferedWriter(new FileWriter(new File("output.txt")));
		int count = Integer.parseInt(br.readLine());
		int yes,surprising,p,numsurprising,current,div3,output;
		String[] buffer;
		int[] values;
		for(int i=1; i<=count; i++)
		{
			String line = br.readLine();
			buffer = line.split(" ");
			values = new int[buffer.length];
			for(int j=0; j<buffer.length; j++)
			{
				values[j] = Integer.parseInt(buffer[j]);
			}
			yes = 0;
			surprising =0;
			p = values[2];
			numsurprising = values[1];
			
			for(int k=3; k<values.length; k++)
			{
				current = values[k];
				div3 = current/3;
				if(current % 3 == 0)
				{
					if(div3 >= p)
					{
						yes++;
					}
					else if(div3 == p-1  && current >= p)
						{
							surprising++;
						}
				}
				else if(current %3 == 1)
				{
					if(div3 >= p-1 && current >= p)
					{
						yes++;
					}
					
				}
				else
				{
					if(div3 >= p-1 && current >= p)
					{
						yes++;
					}
					else if(div3  == p-2 && current >= p)
					{
						surprising++;
					}
				}
					
				
			}
			output = Math.min(yes+surprising, yes+numsurprising);
			//make sure that its not more than the total # of contestants
			//output = Math.min(output, values[0]);
			wr.write("Case #"+i+": "+output);
			
			wr.newLine();
			
		}
		wr.close();
	}
	
}
