import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Scanner;


public class Dancing_With_the_Googlers {


    /**
     * The first line of the input gives the number of test cases, T.
     *  T test cases follow. 
     *  Each test case consists of a single line containing integers separated by single spaces. 
     *  The first integer will be N, the number of Googlers, and the second integer will be S, the number of surprising triplets of scores. 
     *  The third integer will be p, as described above. Next will be N integers ti: the total points of the Googlers. 
     * @throws IOException
     */
	   public static void main(String[] args) throws IOException {
	        // TODO Auto-generated method stub
			// Reading the input file
			Scanner in = new Scanner(new File("B-large.in"));
			// writting the input file
			FileOutputStream fos = new FileOutputStream("B-large.out");
			PrintStream out = new PrintStream(fos);
	         //Close the output stream
	        int testCase=Integer.parseInt(in.nextLine());
	        for(int i=0;i<testCase;i++) {
	        	out.print("Case #" + (i + 1) + ":\t");
	        	int NoOfGooglers= in.nextInt();
	        	int NoOfSurprisingResults = in.nextInt();
	        	int atLeastP=in.nextInt();
	        	ArrayList<Integer> scores= new ArrayList<Integer>();
        		int BestResults=0;
        		int Surprising=0;
	        	for(int j=0;j<NoOfGooglers;j++)
	        	{
	        		scores.add(in.nextInt());
	        		//System.out.print(scores.get(j));
	        		int modulus=scores.get(j)%3;
	        		int temp = scores.get(j);
	    			switch (modulus) {
					case 0:
						if (((temp / 3) >= atLeastP)) {
							BestResults++;
						} else {
							if (((((temp / 3) + 1) >= atLeastP) && ((temp / 3) >= 1))
									&& (Surprising < NoOfSurprisingResults)) {
								BestResults++;
								Surprising++;
								
							}
							System.out.println("Case 0"+"itr:"+i+"  surprising:"+temp);
						}
						
						break;
					case 1:
						if ((temp / 3) + 1 >= atLeastP) {
							BestResults++;
							continue;
						}
						
						break;
					case 2:
						if ((temp / 3) + 1 >= atLeastP) {
							BestResults++;
						} else {
							if (((temp / 3) + 2 >= atLeastP)
									&& (Surprising < NoOfSurprisingResults)) {
								BestResults++;
								Surprising++;
							}
							System.out.println("Case 2"+"itr:"+i+"  surprising:"+temp);
						}
						break;
					default:
						System.out.println("Error");
					}
	    			
				}// Internal for
				out.println(BestResults);
				// System.out.println(BestResults);
				System.out.println(Surprising);
				BestResults = 0;
			}// for
			in.close();
			out.close();
			fos.close();

	   }
}

import java.util.*;

public class B {
	public static void main (String [] args) {
				
		Scanner s = new Scanner(System.in);
		int T = s.nextInt();
		
        int[] normalBestScores = new int[]{
            0, //0: (0, 0, 0)
            1, //1: (1, 0, 0)
            1, //2: (1, 1, 0)
            1, //3: (1, 1, 1)
            2, //4: (2, 1, 1)
            2, //5: (2, 2, 1)
            2, //6: (2, 2, 2)
            3, //7: (3, 2, 2)
            3, //8: (3, 3, 2)
            3, //9: (3, 3, 3)
            4, //10: (4, 3, 3)
            4, //11: (4, 4, 3)
            4, //12: (4, 4, 4)
            5, //13: (5, 4, 4)
            5, //14: (5, 5, 4)
            5, //15; (5, 5, 5)
            6, //16: (6, 5, 5)
            6, //17: (6, 6, 5)
            6, //18: (6, 6, 6)
            7, //19: (7, 6, 6)
            7, //20: (7, 7, 6)
            7, //21: (7, 7, 7)
            8, //22: (8, 7, 7)
            8, //23: (8, 8, 7)
            8, //24: (8, 8, 8)
            9, //25: (9, 8, 8)
            9, //26: (9, 9, 8)
            9, //27: (9, 9, 9)
            10, //28: (10, 9, 9)
            10, //29: (10, 10, 9)
            10 //30: (10, 10, 10)
        };
        
        int[] surpriseBestScores = new int[] {
            -1, //0: None
            -1, //1: None
            2, //2: (2, 0, 0)
            2, //3: (2, 1, 0)
            2, //4: (2, 2, 0)
            3, //5: (3, 1, 1)
            3, //6: (3, 2, 1)
            3, //7: (3, 3, 1)
            4, //8: (4, 2, 2)
            4, //9: (4, 3, 2)
            4, //10: (4, 4, 2)
            5, //11: (5, 3, 3)
            5, //12: (5, 4, 3)
            5, //13: (5, 5, 3)
            6, //14: (6, 4, 4)
            6, //15: (6, 5, 4)
            6, //16: (6, 6, 4)
            7, //17: (7, 5, 5)
            7, //18: (7, 6, 5)
            7, //19: (7, 7, 5)
            8, //20: (8, 6, 6)
            8, //21: (8, 7, 6)
            8, //22: (8, 8, 6)
            9, //23: (9, 7, 7)
            9, //24: (9, 8, 7)
            9, //25: (9, 9, 7)
            10, //26: (10, 8, 8)
            10, //27: (10, 9, 8)
            10, //28: (10, 10, 8)
            -1, //29: None
            -1 //30: None
        };
        
		for (int t = 1; t <= T; t++) {
			int N = s.nextInt();
            int S = s.nextInt();
            int p = s.nextInt();
            int[] tp = new int[N];
            for (int i = 0; i < N; i++)
                tp[i] = s.nextInt();
			Arrays.sort(tp);
            int ans = 0;
            for (int i = N-1; i >= 0; i--) {
                if (normalBestScores[tp[i]] >= p) {
                    ans++;
                } else if (S > 0 && tp[i] >= 2 && tp[i] <= 28) {
                    S--;
                    if (surpriseBestScores[tp[i]] >= p) {
                        ans++;
                    }
                }            
            }
            
			System.out.println("Case #" + t + ": "+ans);
		}
	}
}