/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package codejam.common;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Lance Chen
 */
public class CodeHelper {

    private static String FILE_ROOT = "D:/workspace/googlecodejam/meta";

    public static List<List<String>> loadInputsExcludes(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        int index = 0;
        for (String line : lines) {
            if (index == 0) {
                index++;
                continue;
            }
            if (index % 2 == 1) {
                index++;
                continue;
            }
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
            index++;
        }
        return result;
    }

    public static List<List<String>> loadInputs(String fileName) {
        List<List<String>> result = new ArrayList<List<String>>();
        List<String> lines = FileUtil.readLines(FILE_ROOT + fileName);
        for (String line : lines) {
            List<String> dataList = new ArrayList<String>();
            String[] dataArray = line.split("\\s+");
            for (String data : dataArray) {
                if (data.trim().length() > 0) {
                    dataList.add(data);
                }
            }
            result.add(dataList);
        }
        return result;
    }

    public static List<String> loadInputLines(String fileName) {
        return FileUtil.readLines(FILE_ROOT + fileName);
    }

    public static void writeOutputs(String fileName, List<String> lines) {
        FileUtil.writeLines(FILE_ROOT + fileName, lines);
    }
}

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package a;

import java.io.File;
import java.io.PrintWriter;
import java.util.Scanner;
import java.io.IOException;

/**
 *
 * @author KazakhPride
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        Scanner in = new Scanner(new File("B-small-attempt0.in"));
        PrintWriter out = new PrintWriter(new File("output.txt"));

        int n = in.nextInt();
        int t = 0;
        int s = 0;
        int p = 0;
        
        for (int j = 1; j <= n; j++) {
            out.print("Case #" + j + ": ");
            t = in.nextInt();
            s = in.nextInt();
            p = in.nextInt();
            int count = 0;
            int ar[] = new int[t];
            for (int i = 0; i < ar.length; i++) {
                ar[i] = in.nextInt();
            }
            
            for( int i = 0; i < ar.length; i++ ){
                if(ar[i]%3 == 0){
                    int base = ar[i]/3;
                    //int second = first;
                    //int third = second;
                    if(base >= p){
                        count++;
                    }
                    else{
                        if(s > 0 && base > 0 && base + 1 >= p){
                            count++;
                            s--;
                        }
                    }
                }
                else if(ar[i]%3==1){
                    int base = ar[i]/3;
                    
                    if(base >= p || base + 1 >= p){
                        count++;
                    }
                    else{
                        if(s > 0 && base + 1 >= p){
                            count++;
                            s--;
                        }
                    }
                }
                if( ar[i]%3 == 2 ){
                    int base = ar[i]/3;
                    
                    if(base + 1 >= p || base >= p){
                        count++;
                    }
                    else{
                        if( s > 0 && base + 2 >= p ){
                            count++;
                            s--;
                        }
                    }
                }
            }
            out.println(count);
        }
        in.close();
        out.close();
    }
}