import java.io.*;
import java.math.*;
import java.util.*;
import java.text.*;

public class b {
    public static void main(String[] args) {
        Scanner sc = new Scanner(new BufferedInputStream(System.in));

        int T = sc.nextInt();

        for (int casenumber = 1; casenumber <= T; ++casenumber) {

            int n = sc.nextInt();
            int s = sc.nextInt();
            int p = sc.nextInt();

            int[] ts = new int[n];
            for (int i = 0; i < n; ++i)
                ts[i] = sc.nextInt();

            int thresh1 = (p == 1 ? 1 : (3 * p - 4));
            int thresh2 = (3 * p - 2);

            int count1 = 0, count2 = 0;

            for (int i = 0; i < n; ++i) {
                if (ts[i] >= thresh2) {
                    ++count2;
                    continue;
                }
                if (ts[i] >= thresh1) {
                    ++count1;
                }
            }

            if (count1 > s) {
                count1 = s;
            }

            System.out.format("Case #%d: %d%n", casenumber, count1 + count2);
        }
    }
}

package codejam;

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

public class ProblemB
{
    public static void main(String[] args) throws FileNotFoundException
    {
        Scanner sc = new Scanner(new File("B-small-attempt0.in"));
        sc.nextLine(); // input size
        int cases = 0;
        while(sc.hasNext())
        {
            String line = sc.nextLine();
            String[] vals = line.split(" ");
            int googlerCount = Integer.parseInt(vals[0]);
            int maxSupriseCount = Integer.parseInt(vals[1]);
            int limit = Integer.parseInt(vals[2]);
            int[] scores = new int[vals.length - 3];
            for(int i = 0; i < vals.length - 3; i++)
            {
                scores[i] = Integer.parseInt(vals[i+3]);
            }

            int output = 0;
            int supriseCount = 0;
            for(int score : scores)
            {
                if (score == 0 && limit > 0) {
                    continue;
                }
                double avg = score / 3d;
                if (avg >= limit)
                {
                    output++;
                }
                else if (limit - avg < 1) {
                    output++;
                }
                else if (limit - avg < 1.5) {
                    if (supriseCount < maxSupriseCount) {
                        supriseCount++;
                        output++;
                    }
                }
            }
            System.out.println("Case #" + ++cases + ": " + output);
            
        }
    }
}
