package code12.qualification;

import java.io.File;
import java.io.FileWriter;
import java.util.Scanner;

public class B {
	public static String solve(int N, int S, int p, int[] t) {
		
		// 3a 		-> (a, a, a), *(a - 1, a, a + 1)
		// 3a + 1	-> (a, a, a + 1), *(a - 1, a + 1, a + 1)
		// 3a + 2	-> (a, a + 1, a + 1), *(a, a, a + 2)
		
		int numPNoS = 0;
		int numPWithS = 0;
		
		for (int i = 0; i < N; i++) {
			int a = (int)Math.floor(t[i] / 3);
			int r = t[i] % 3;
			
			switch (r) {
			case 0:
				if (a >= p) {
					numPNoS++;
				} else if (a + 1 >= p && a - 1 >= 0) {
					numPWithS++;
				}
				break;
			case 1:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				}
				break;
			case 2:
				if (a >= p || a + 1 >= p) {
					numPNoS++;
				} else if (a + 2 >= p) {
					numPWithS++;
				}
				break;
			}
		}
		
		return "" + (numPNoS + Math.min(S, numPWithS));
	}

	public static void main(String[] args) throws Exception {
		// file name
		//String fileName = "Sample";
		//String fileName = "B-small";
		String fileName = "B-large";
		
		// file variable
		File inputFile = new File(fileName + ".in");
		File outputFile = new File(fileName + ".out");
		Scanner scanner = new Scanner(inputFile);
		FileWriter writer = new FileWriter(outputFile);

		// problem variable
		int totalCase;
		int N, S, p;
		int[] t;

		// get total case
		totalCase = scanner.nextInt();

		for (int caseIndex = 1; caseIndex <= totalCase; caseIndex++) {
			// get input
			N = scanner.nextInt();
			S = scanner.nextInt();
			p = scanner.nextInt();
			t = new int[N];
			
			for (int i = 0; i < N; i++) {
				t[i] = scanner.nextInt();
			}
			
			String output = "Case #" + caseIndex + ": " + solve(N, S, p, t);
			System.out.println(output);
			writer.write(output + "\n");
		}
		scanner.close();
		writer.close();
	}
}

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

public class Triplets {

	public static void main(String[] args) throws IOException {
		new Triplets().run("B-large.in");
//		new Triplets().run("problem.txt");
	}

	public void run(String fileName) throws IOException {
		parseFile(fileName);
	}

	private void parseFile(String fileName) throws FileNotFoundException {
		File file = new File(fileName);
		Scanner scanner = new Scanner(file);

		int numTests = Integer.parseInt(scanner.nextLine());
		for (int i = 1; i <= numTests; i++) {
			System.out.println("Case #" + i + ": " + solve(scanner.nextLine()));
		}
		scanner.close();
	}

	public String solve(String line) {
		Scanner ls = new Scanner(line);
		int num = ls.nextInt();
		int suprises = ls.nextInt();
		int p = ls.nextInt();
		int[] tps = new int[num];
		for (int i = 0; i < tps.length; i++) {
			tps[i] = ls.nextInt();
		}

		Solver solver = new Solver(suprises, p, tps);

		return Integer.toString(solver.solve());
	}
}

class Solver {
	private int surprises;
	private final int p;
	private final int[] tps;

	Solver(int suprises, int p, int[] tps) {
		this.surprises = suprises;
		this.p = p;
		this.tps = tps;
	}

	public int solve() {
		int possibles = 0;
		if (p == 0)
			return tps.length;

		for (int tp : tps) {
			if (tp % 3 == 0 && tp != 0) {
				int mp = tp / 3;
				if (mp >= p) {
					possibles++;
				} else if ((mp + 1) >= p && surprises > 0) {
					surprises--;
					possibles++;
				}
			} else if (tp % 3 == 1) {

				int mp = tp / 3 + 1;
				if (mp >= p)
					possibles += 1;

			} else if (tp % 3 == 2) {
				int mp = tp / 3 + 1;
				if (mp >= p) {
					possibles++;
				} else if ((mp + 1) >= p && surprises > 0) {
					surprises--;
					possibles++;
				}
			}
		}

		return possibles;
	}

}
