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 codejam;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Googler
{

    public static void main(String[] args) throws Exception
    {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int i =1;
        int n = Integer.parseInt(reader.readLine());
        for(; i<=n; i++)
        {
            String input = reader.readLine();
            System.out.print("Case #" + i + ": ");
            String[] sp = input.split(" ");
            int numData  = Integer.parseInt(sp[0]);
            int s = Integer.parseInt(sp[1]);
            int p = Integer.parseInt(sp[2]);
            
            int[] data = new int[numData];
            for(int j=0; j<numData; j++)
            {
                data[j] = Integer.parseInt(sp[j+3]);
            }
            System.out.println(count(data, s, p));
        }
    }
    
    public static int count(int[] data, int s, int p)
    {
        Arrays.sort(data);
        int count = 0;
        for(int i=data.length-1; i>=0 && s>=0; i--)
        {
            if(data[i] % 3 == 0)
            {
                if(data[i]/3 >= p)
                {
                    count++;
                    continue;
                }
                else if(data[i]/3 + 1 >=p && s>0 && data[i]/3 -1 >=0)
                {
                    count++;
                    s--;
                    continue;
                }
                else
                {
                    break;
                }
            }
            else if(data[i] % 3 == 2)
            {
                if((data[i]/3 >= p) || data[i]/3 + 1 >=p)
                {
                    count++;
                    continue;
                }
                else if(data[i]/3 + 2 >=p && s>0)
                {
                    count++;
                    s--;
                    continue;
                }
                else
                {
                    break;
                }
            }
            else
            {
                if((data[i]/3 >= p) || data[i]/3 + 1 >=p)
                {
                    count++;
                    continue;
                }
                else if(data[i]/3 - 1 >=p && s>0 && data[i]/3 - 1>=0)
                {
                    count++;
                    s--;
                    continue;
                }
                else
                {
                    break;
                }
            }
        }
        
        return count;
    }
    
}
