import java.util.List;


public class Case implements Runnable {

	private int id;
	private String output;

	private int n;
	private int s;
	private int p;
	private List<Integer> g;

	public Case(int id) {
		this.id = id;
	}

	public Case(int id, int n, int s, int p, List<Integer> g) {
		super();
		this.id = id;
		this.n = n;
		this.s = s;
		this.p = p;
		this.g = g;
	}

	public String solve() {
		int res = 0;
		for (int googler : g) {
			int b = googler / 3;
			boolean div = googler % 3 == 0;
			if (b >= p) {
				res++;
				continue;
			}
			if (p == b+1) {
				if (div && s > 0 && b > 0) {
					res++;
					s--;
					continue;
				}
				if (!div) {
					res++;
					continue;
				}
			}
			if (p == b+2) {
				if (3*b+2 == googler && s > 0) {
					res++;
					s--;
				}
			}
		}
		return String.valueOf(res);
	}

	@Override
	public void run() {
		output = solve();
	}

	@Override
	public String toString() {
		return "Case #" + id + ": " + output;
	}

}
package jam2012.qround;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;

public class PB {
	public static void main(String args[])
	{
		int line = 0;
		try{
			BufferedReader br = new BufferedReader(new FileReader("B-small-attempt0.in"));
			BufferedWriter bw = new BufferedWriter(new FileWriter("B-small-attempt0.out"));
			String str;
			String[] strIn;
			Integer.parseInt(br.readLine());
			while ((str = br.readLine()) != null){
				strIn = str.split(" ");
				int i=0;
				int N = Integer.parseInt(strIn[i++]);
				int S = Integer.parseInt(strIn[i++]);
				float p = Integer.parseInt(strIn[i++]);
				int cases = 0;
				while(N>0){
					float score = Integer.parseInt(strIn[i++]);
					N--;
					if (score >= (3*p-2))
						cases++;
					else 
						if (score >= (3*p-4) && S>0 && score >=2){
							cases++;
							S--;
						}	
				}
				line++;
				bw.write("Case #"+line+": "+cases);
				bw.newLine();
			}
			br.close();
			bw.close();
		}catch (Exception e){//Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}
}
