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

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 DancingWithTheGooglers {

	
	public static void main(String[] args) throws IOException {
		

		BufferedReader br=new BufferedReader(new FileReader(new File("./dancingwiththegooglers/b-small-attempt1.in")));
		BufferedWriter bw=new BufferedWriter(new FileWriter(new File("./dancingwiththegooglers/small1.out")));
		
		int numberOfCase=Integer.parseInt(br.readLine());
		
		StringBuilder out=new StringBuilder();
		
		for(int i=1;i<=numberOfCase;i++){
			int count=0;
			out.append("Case #"+i+": ");
			
			String[]input=br.readLine().split(" ");
			
			int surprising=Integer.parseInt(input[1]);
			int goal=Integer.parseInt(input[2]);
			int googlers=Integer.parseInt(input[0]);
			for(int j=3;j<3+googlers;j++){
				
				int result=check(Integer.parseInt(input[j]),goal,surprising);
				if(result==0){
					count++;
					surprising--;
				}
				if(result==1)
					count++;
				
					
				
			}
			
			
			
			out.append(count);
			if(i<numberOfCase)
				out.append("\n");			
			
			
		}
		bw.write(out.toString());
		br.close();
		bw.close();
		

	}
	
	/*
	 * return  1 - possible to achieve goal and is not surprising
	 *         0 - possible to achieve goal and is surprising
	 *         -1 - impossible to achieve goal
	 */
	public static int check(int totalScore,int goal,int surprising){
		
		if(totalScore<goal)
			return -1;
		
		int r=totalScore%3;
		int max=-1;
		if(r==0)
			max=totalScore/3;
		if(r==1)
			max=(int)Math.ceil(totalScore/3.0);
		if(r==2)
			max=(int)Math.ceil(totalScore/3.0);
		
		if(max<goal)
			if(surprising==0)
				return -1;
			else{
				if(totalScore>=goal+(goal-2)+(goal-2))
					return 0;
				else
					return -1;
			}
		else
			return 1;
		
	}

}
