/*
 * 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);
    }
}

import java.util.HashMap;
import java.util.Map;

public class ProblemB {
	public static void main(String argv[])
	{
		IOSystem ioSystem = new IOSystem("problem/B-small-attempt0");
////		IOSystem ioSystem = new IOSystem("problem/A-small-attempt2");
//		IOSystem ioSystem = new IOSystem("problem/test");

		ioSystem.nextLong();
		while(ioSystem.hasNext())
		{
			int N = ioSystem.nextInt();
			int S = ioSystem.nextInt();
			int P = ioSystem.nextInt();

			int koeru = 0;
			int supKoeru = 0;

			for(int i=0;i<N;i++)
			{
				int t = ioSystem.nextInt();
				if(t==0)
				{
					if(P == 0)koeru++;
					continue;
				}
				if(t==1)
				{
					if(P <= 1)koeru++;
					continue;
				}



				//3ã¤ã«åãã
				if(t%3==0)
				{
					if(t/3>= P)
					{
						koeru++;
					}
					else if(t/3 + 1>= P)
					{
						supKoeru++;
					}
				}
				else if(t%3 == 2)
				{
					if(t/3 + 1>= P)
					{
						koeru++;
					}
					else if(t/3 + 2>= P)
					{
						supKoeru++;
					}
				}
				else
				{
					if(t/3 + 1 >= P)
					{
						koeru++;
					}
				}
			}

			System.out.println(N+","+S+","+P+","+koeru+","+supKoeru);

			if(supKoeru > S)
			{
				koeru += S;
			}
			else
			{
				koeru += supKoeru;
			}


			ioSystem.appendAnswer(koeru);
		}

		ioSystem.output();
	}
}


