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

}

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class Googlers {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		
		
		String fichier ="C:\\result.txt";
		int compteurlignes = 0;
		int nombreCas ;
		ArrayList<String> googlers = new ArrayList<String>();
		ArrayList<String> results = new ArrayList<String>();
		//lecture du fichier texte	
		try
		{
			InputStream ips=new FileInputStream(fichier); 
			InputStreamReader ipsr=new InputStreamReader(ips);
			BufferedReader br=new BufferedReader(ipsr);
			String ligne;
			while ((ligne=br.readLine())!=null){
				compteurlignes++;
				//System.out.println(ligne);
				if (compteurlignes ==1)
				{
					nombreCas = Integer.valueOf(ligne);
				}
				else
				{
					googlers.add(ligne);
					//System.out.println(ligne);
				}
				
			}
			br.close(); 
			
		
			
			
			//traitement par ligne
			ArrayList<String> nombres = new ArrayList<String>();
			for(int i = 0; i < googlers.size();i++)
			{
				 ligne = googlers.get(i);
				 
				 
				 //get numbers
				 StringTokenizer st = new StringTokenizer(ligne, " ");
				    while (st.hasMoreTokens())
				    {
				      nombres.add(st.nextToken());
				      
				    }
				    
				    int numberGooglers = Integer.parseInt(nombres.get(0));
				    int surprises = Integer.parseInt(nombres.get(1));
				    int chiffre = Integer.parseInt(nombres.get(2));
				    int value = 0;
				    
				    int totalNumber = chiffre *3;
				    
				    for(int x = 0; x < numberGooglers; x++)
				    {
				    	int totalMark = Integer.parseInt(nombres.get(x+3));
				    	
				    	if(totalNumber ==0)
				    	{
				    		value++;
				    	}
				    	else if(totalMark <= totalNumber+2 && totalMark >= totalNumber-2)
				    	{
				    		value++;
				    	}
				    	else if(totalMark == totalNumber-3 || totalMark == totalNumber-4)
				    	{
				    		if (surprises >0 && totalMark != 0)
				    		{
				    			surprises--;
				    			value++;
				    		}
				    	}
				    	else if(totalMark >= totalNumber+3) value++;
				    }
				    
				    results.add(String.valueOf(value));
				    System.out.println("result : "+value);
				    //clean arrayList
				    nombres = new ArrayList<String>();
			}
		
		
		
		}
		catch (Exception e)
		{
			System.out.println(e.toString());
		
		}
		
		
		
		
		
		//écrire dans le fichier
		try 
		{
			FileWriter fw = new FileWriter (fichier);
			BufferedWriter bw = new BufferedWriter (fw);
			PrintWriter fichierSortie = new PrintWriter (bw); 
			for (int w =0; w<results.size();w++)
			{
				fichierSortie.println ("Case #"+(w+1)+": "+results.get(w)); 
			}
			fichierSortie.close();
			System.out.println("Le fichier " + fichier + " a été créé!"); 
		}
		catch (Exception e)
		{
			System.out.println(e.toString());
		}	

	}

}
