import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;


public class Dancing_improved {
	
	static int f_Superan_limites(String params){
		  int superan_limite=0;
		  String[] parametros=params.split(" ");
		  
		  int n_participantes= Integer.parseInt(parametros[0]);
		  int n_sorprendidos= Integer.parseInt(parametros[1]);
		  int nota_limite= Integer.parseInt(parametros[2]);
		  
		  int suma_notas, resto, nota_juego;
		  for(int i=3;i<parametros.length;i++){ // Recorro las sumas de los participantes
			  
			  suma_notas=Integer.parseInt(parametros[i]);
			  resto=suma_notas%3;
			  
			  if(resto==0){ // el resto es el número triplicado!
				  nota_juego=suma_notas/3;
				  if(nota_juego>=nota_limite){
					  superan_limite++;
				  }else if(nota_juego-1>=0 && n_sorprendidos>0 && ((nota_juego+1)>=nota_limite || (nota_juego+2)>=nota_limite)){ // no supera el límite pero podría hacerlo si quedan sorprendidos
					  n_sorprendidos--;
					  superan_limite++;
				  }
			  }else if((suma_notas+1)%3==0){ // Tendré que jugar con el valor en +-1
				  nota_juego=(suma_notas+1)/3;
				  if(nota_juego-1>=0 && nota_juego>=nota_limite){
					  superan_limite++;
				  }else if(nota_juego-1>=0 && n_sorprendidos>0 && (nota_juego+1)>=nota_limite){
					  n_sorprendidos--;
					  superan_limite++;
				  }
			  }else if((suma_notas+2)%3==0){ // Tendré que jugar con el valor en +-2
				  nota_juego=(suma_notas+2)/3;
				  if(nota_juego-1>=0 && nota_juego>=nota_limite){
					  superan_limite++;
				  }		  
			  }			  
		  }
		  return superan_limite;
	}
	
	public static void main(String[] args) throws IOException {
		FileReader fr = new FileReader(args[0]);
		BufferedReader bf = new BufferedReader(fr);
		int ntest=0;
		
		FileWriter fstream = new FileWriter("out.txt");
		BufferedWriter out = new BufferedWriter(fstream);
		
		String lines = bf.readLine();
		String liner, linew;
		int lines_r=0;
		String[] numbers;
		int total;
		
		while((liner = bf.readLine())!=null && lines_r<=Integer.parseInt(lines)) {
			ntest++;
			numbers=liner.split(" ");
			total=f_Superan_limites(liner);
			linew="Case #"+ntest+": "+total+"\n";
			out.write(linew);
			lines_r++;
		}
		out.close();
		fr.close();
	}
}

/**
 * 
 */
package code.google.codejam;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * @author sunilkumarp
 *
 */
public abstract class Template {
	
	int testcases = 0;
	
	int casePoniter = 0;
	
	PrintWriter writer = null;
	
	BufferedReader reader = null;
	
	String line = null;
	
	int linePointer = -1;
	
	int linePerTestCase = 1;
	
	char lastChar = '!';
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			Template template = (Template) Class.forName(args[1]).newInstance(); 
			template.start(args);
		} catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace(System.out);
		}

	}



	/**
	 * @param args
	 */
	protected void start(String[] args) {
		InputStream io = null;
		OutputStream os = null;
		
		
		
		try {
			
			io = Template.class.getResourceAsStream(args[0]);
			reader = new BufferedReader(new InputStreamReader (io));
			os = new FileOutputStream(new File(args[0].substring(0, args[0].length() -2 )+ "out"));
			writer = new PrintWriter(os);
			testcases = Integer.valueOf(reader.readLine());
			
			solveProblem();
			
			
		} catch (Exception e) {
			System.out.println(e.getMessage());
			e.printStackTrace(System.out);
		} finally {
			try {
				writer.flush();
				writer.close();
			} catch (Exception e) {
				System.out.println(e.getMessage());
				e.printStackTrace(System.out);
			}

			try {
				reader.close();
			} catch (Exception e) {
				System.out.println(e.getMessage());
				e.printStackTrace(System.out);
			}

			try {
				io.close();
			} catch (Exception e) {
				System.out.println(e.getMessage());
				e.printStackTrace(System.out);
			}

			try {
				os.flush();
				os.close();
			} catch (Exception e) {
				System.out.println(e.getMessage());
				e.printStackTrace(System.out);
			}
		}
	}

	public void solveProblem() throws Exception {
		long sTime = System.nanoTime();
		for (;++casePoniter <= testcases;) {
			long sTimeCase = System.nanoTime();
			writeOutput(casePoniter, solveProblemForATestCase());
			System.out.println("Time taken for test case" + "[" + casePoniter + "]:" + (System.nanoTime() - sTimeCase));
		}

		System.out.println("Total time for all test cases:" + (System.nanoTime() - sTime));
	}
	
	protected Object solveProblemForATestCase() throws Exception {
		initializeTestCase();
		printInput();
		return doSolveProblem();
	}

	protected abstract Object doSolveProblem() throws Exception;

	protected abstract void printInput() throws Exception;

	protected abstract void initializeTestCase() throws Exception;

	protected void writeOutput (int caseNo, Object result) {
		String str = "Case #" + caseNo + ": " + result;
		System.out.println("==========" + str + "=============");
		writer.println(str);
	}
	
	public char readChar() throws IOException {
		return lastChar = (char)reader.read();
	}
	
	public char readCharFromLine() throws IOException {
		int length = line.length();
		
		if (linePointer >= length - 1) {
			throw new IllegalStateException("Line has already ended.");
		}
		
		return line.charAt(++linePointer);
	}
	
	public String readLine() throws IOException {
		line = reader.readLine();
		linePointer = -1;
		return line;
	}
	
	public int readNextInteger() {
		int val = 0;
		int length = line.length();
		
		if (linePointer >= length) {
			throw new IllegalStateException("Line has already ended.");
		}
		
		while(++linePointer < length) {
			if (Character.isDigit(lastChar = line.charAt(linePointer))) {
				val = val * 10 + Character.digit(lastChar, 10);
			} else {
				break;
			}
		}
		
		return val;
	}
	
}
