package com.silverduner.codejam;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.HashMap;

public class Dancing {
	public static void main(String[] args) throws Exception {
		File input = new File("B-small-attempt0.in");
		BufferedReader in = new BufferedReader(new FileReader(input));

		File output = new File("1.out");
		BufferedWriter out = new BufferedWriter(new FileWriter(output));

		// parse input
		int N = Integer.parseInt(in.readLine());
		for(int i=0;i<N;i++) {
			String str = in.readLine();
			out.write("Case #"+(i+1)+": ");
			System.out.println("-------");
			String[] words = str.split(" ");
			int n = Integer.parseInt(words[0]);
			int suprise = Integer.parseInt(words[1]);
			int threshold = Integer.parseInt(words[2]);
			int[] scores = new int[n];
			for(int j=0;j<n;j++) {
				scores[j] = Integer.parseInt(words[3+j]);
			}
			int count = 0;
			for(int score : scores) {
				int a,b,c;
				boolean find = false;
				boolean sfind = false;
				for(a = 10; a>=0 && !find; a--) {
					if(3*a-4>score)
						continue;
					for(b = a; b>=0 && b >=a-2 && !find; b--) {
						for(c = b; c>=0 && c >=b-2 && c >=a-2 && !find; c--) {
							System.out.println(a+","+b+","+c);
							if(a+b+c==score) {
								if(a >= threshold) {
									if(a-c <= 1){
										count++;
										find = true;
										System.out.println("find!");
									}
									else if(a-c == 2){
										sfind = true;
										System.out.println("suprise!");
									}
								}
							}
							
						}
					}
				}
				if(!find && sfind && suprise > 0)
				{
					count++;
					suprise --;
				}
			}
			int maxCount = count;
			out.write(maxCount+"\n");
		}
		out.flush();
		out.close();
		in.close();
	}
}

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GoogleDancers {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();
		int numberOfTestCases = Integer.parseInt(s);

		StringBuffer output = new StringBuffer();
		for (int i = 1; i <= numberOfTestCases; i++) {
			String testCase = br.readLine().trim();
			String[] inputparams = testCase.split(" ");

			long N, S, p;
			long totalPoints[] = new long[110];

			N = Long.parseLong(inputparams[0]);
			S = Long.parseLong(inputparams[1]);
			p = Long.parseLong(inputparams[2]);

			for (int j = 3; j <= N + 2; j++) {
				totalPoints[j - 3] = Long.parseLong(inputparams[j]);
			}

			String outputString = solveTestCase(N, S, p, totalPoints);

			if (i != 1) {
				output.append("\n");
			}

			output.append("Case #" + i + ": ");
			output.append(outputString);
		}

		System.out.println(output);
	}

	private static String solveTestCase(long N, long S, long p, long[] totalPoints) {
		long maxNoOfBest = 0;
		long possibleSuprises = 0;

		for (int i = 0; i < N; i++) {
			int totalPnts = (int) totalPoints[i];
			int oneScore = totalPnts / 3;
			int mod = totalPnts % 3;

			if (mod >= 1) {
				if (oneScore >= p || (oneScore + 1) >= p) {
					maxNoOfBest++;
				} else if (oneScore + mod >= p) {
					possibleSuprises++;
				}
			} else {
				if (oneScore >= p) {
					maxNoOfBest++;
				} else if (oneScore > 0 && oneScore + 1 >= p) {
					possibleSuprises++;
				}
			}
		}

		if (possibleSuprises < S) {
			maxNoOfBest = maxNoOfBest + possibleSuprises;
		} else {
			maxNoOfBest = maxNoOfBest + S;
		}

		return String.valueOf(maxNoOfBest);
	}
}
