package codejam;

import fixjava.Pair;

public class Utils {

	public static long minLong(long firstVal, long... otherVals) {
		long minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static int minInt(int firstVal, int... otherVals) {
		int minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	public static float minFloat(float firstVal, float... otherVals) {
		float minVal = firstVal;
		for (int i = 0; i < otherVals.length; i++)
			minVal = Math.min(firstVal, otherVals[i]);
		return minVal;
	}

	/**
	 * ArgMin returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMin(int[] arr) {
		int min = arr[0];
		int argMin = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] < min) {
				min = arr[i];
				argMin = i;
			}
		}
		return new Pair<Integer, Integer>(argMin, min);
	}

	/**
	 * ArgMax returned as a Pair<Integer, Integer>(index, value). Array must
	 * have at least one value.
	 */
	public static Pair<Integer, Integer> argMax(int[] arr) {
		int max = arr[0];
		int argMax = 0;
		for (int i = 1; i < arr.length; i++) {
			if (arr[i] > max) {
				max = arr[i];
				argMax = i;
			}
		}
		return new Pair<Integer, Integer>(argMax, max);
	}

}

/**
 * User: avokin
 * Date: 4/14/12
 */
public class ProblemB {
    private static int solve(int n, int s, int p, int[] t) {
        int result = 0;
        for (int i = 0; i < n; i++) {
            if (t[i] % 3 == 0) {
                int a = t[i] / 3;
                if (a >= p) {
                    result++;
                } else {
                    if (a > 0 && a + 1 == p && s > 0) {
                        s--;
                        result++;
                    }
                }
            } else if (t[i] % 3 == 1) {
                int a = t[i] / 3 + 1;
                if (a >= p) {
                    result++;
                }
            } else {
                int a = t[i] / 3 + 1;
                if (a >= p) {
                    result++;
                } else {
                    if (a + 1 == p && s > 0) {
                        s--;
                        result++;
                    }
                }
            }
        }
        return result;
    }

    public static void main(String[] args) {
        String input = "100\n" +
                "6 2 8 29 20 8 18 18 21\n" +
                "77 11 7 17 26 7 17 17 8 19 30 17 19 26 7 17 18 28 4 18 14 3 28 18 18 18 18 18 13 6 17 18 24 15 17 28 26 20 17 18 18 6 17 9 4 19 18 19 17 16 18 18 17 17 17 18 17 3 17 9 18 18 17 22 16 27 18 18 4 17 18 18 18 18 9 0 10 10 30 17\n" +
                "58 58 9 28 28 17 2 25 12 9 17 16 5 6 6 24 5 28 5 21 12 16 27 14 15 24 16 13 10 3 28 13 14 9 17 21 2 11 16 13 8 17 25 14 6 8 7 8 16 9 10 16 14 2 15 17 19 9 18 23 2\n" +
                "63 63 1 13 14 12 8 13 20 27 24 17 22 6 14 7 23 12 15 3 19 25 7 16 21 10 20 28 14 26 12 4 2 7 9 9 15 6 22 12 21 22 6 10 11 5 21 17 9 19 18 21 28 12 28 17 19 20 3 11 21 5 15 18 12 25\n" +
                "91 22 8 4 21 9 0 7 21 21 30 21 23 24 30 21 18 20 21 20 21 17 27 20 20 21 7 20 28 20 17 21 17 2 3 20 10 16 20 1 20 21 21 15 1 23 21 21 21 25 22 21 20 20 3 21 20 21 20 20 21 0 18 20 20 8 14 21 0 30 20 20 21 7 20 21 21 3 4 20 20 1 0 21 11 25 20 2 21 21 21 9 21 20\n" +
                "54 18 4 21 21 26 1 22 12 14 9 8 9 8 30 17 9 9 27 9 9 8 9 9 9 22 8 9 9 8 9 9 29 5 8 8 29 8 19 8 9 9 15 9 8 8 9 25 3 8 6 9 13 24 0 26 21\n" +
                "38 11 5 2 14 11 14 18 7 21 23 11 23 1 6 17 3 10 8 3 25 24 8 27 16 11 17 24 19 3 2 25 29 12 14 29 28 18 3 19 17\n" +
                "59 17 10 26 27 26 4 27 0 27 26 27 27 2 28 26 27 27 15 27 26 26 5 26 27 30 20 23 27 27 26 14 26 27 1 26 27 19 18 26 19 9 26 27 26 0 26 26 27 26 27 27 27 21 26 27 17 27 26 26 26 27\n" +
                "100 0 3 16 28 2 13 7 2 29 11 22 12 4 1 8 4 28 21 2 9 13 3 1 27 15 17 7 2 26 9 23 24 13 6 7 0 7 26 19 14 24 30 29 25 8 16 26 27 10 12 24 22 2 13 6 7 30 4 9 12 0 5 4 29 25 8 3 18 11 14 20 19 26 15 5 30 14 15 30 0 24 24 5 10 6 28 29 19 14 1 24 1 24 10 29 14 13 13 8 8 29 19\n" +
                "25 8 3 9 17 8 18 10 6 18 3 22 8 9 4 16 24 14 28 21 15 28 5 7 26 21 6 2\n" +
                "50 26 6 0 17 29 8 25 1 1 11 17 20 23 18 16 4 20 17 29 30 4 15 23 18 11 15 26 14 28 9 19 11 22 5 12 21 3 1 19 1 30 29 20 8 13 29 16 11 29 3 10 9\n" +
                "46 18 5 11 7 11 1 11 12 12 17 11 12 21 12 11 11 11 11 12 27 11 9 24 12 11 11 11 12 28 25 29 11 12 12 9 20 12 11 9 11 12 12 11 11 12 11 12 12\n" +
                "5 1 8 21 1 20 14 4\n" +
                "65 0 1 17 15 13 6 27 20 29 4 2 21 13 5 3 19 23 29 23 6 17 19 17 30 1 20 16 4 19 5 22 18 13 11 5 20 22 24 10 6 21 6 15 18 10 6 9 25 19 15 13 15 28 24 0 12 21 9 4 12 28 22 29 21 13 25 13\n" +
                "15 0 10 20 26 8 9 26 26 26 13 27 27 27 18 27 15 26\n" +
                "8 1 8 27 15 30 17 5 26 26 9\n" +
                "61 0 0 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30\n" +
                "100 22 4 25 8 0 27 9 8 6 6 9 8 6 9 8 0 20 9 20 25 8 3 6 8 8 9 17 8 9 5 0 8 21 8 8 8 0 11 0 9 8 1 9 8 9 20 13 8 4 9 8 8 9 4 9 10 22 4 12 17 30 8 8 27 8 9 8 9 9 2 8 12 9 8 0 9 8 13 9 1 15 6 24 23 8 9 9 8 9 9 0 9 8 6 9 9 30 8 6 15 27 8\n" +
                "62 0 10 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30 30\n" +
                "8 5 7 28 19 17 5 29 10 12 8\n" +
                "84 84 3 21 28 17 21 24 2 11 23 16 12 25 28 8 12 7 3 18 20 25 18 17 10 20 8 3 3 7 24 27 19 9 5 5 6 5 3 2 7 13 10 7 10 16 25 3 3 23 14 13 8 28 15 22 8 8 27 3 27 10 20 9 22 3 20 12 18 28 5 22 20 10 18 17 11 8 19 21 16 16 10 6 3 2 27\n" +
                "92 52 10 27 19 5 23 19 29 11 10 12 1 20 28 11 5 17 7 17 5 2 3 27 19 3 0 24 17 21 5 29 11 26 25 26 21 25 7 15 6 11 20 24 27 4 13 3 27 19 10 4 27 11 7 16 27 25 8 11 16 18 29 27 25 21 7 23 14 5 30 18 5 8 22 14 29 12 13 24 13 25 15 10 29 18 2 2 22 19 0 15 1 22 0\n" +
                "34 18 9 24 24 23 23 29 24 23 23 25 15 24 9 24 14 10 24 3 24 21 23 24 30 23 14 30 7 23 24 23 24 23 9 29 30\n" +
                "65 31 6 25 16 15 5 26 14 0 12 15 15 17 14 10 14 14 14 4 1 25 14 24 14 14 15 13 16 20 14 15 14 4 9 0 14 8 14 14 15 15 15 4 15 1 14 15 14 14 2 15 15 14 9 14 3 30 15 14 15 15 14 15 16 15 7 26\n" +
                "19 11 1 26 8 20 19 18 14 14 20 17 7 1 28 9 20 17 2 8 24 27\n" +
                "31 24 9 22 14 29 0 5 22 26 15 27 1 17 24 5 8 18 30 12 4 30 8 27 10 17 29 25 9 7 16 11 25 7\n" +
                "33 33 0 3 3 27 26 27 23 18 25 21 12 24 10 22 12 28 19 12 11 11 28 2 27 18 13 4 24 4 4 13 15 3 24 7\n" +
                "58 28 7 17 27 18 6 18 18 18 18 18 5 29 18 18 18 22 9 17 18 26 17 17 17 18 18 13 18 17 18 17 24 4 5 17 21 17 17 17 17 17 4 18 24 16 10 18 27 6 18 8 13 15 26 18 3 11 9 17 30\n" +
                "16 12 10 11 15 16 5 5 21 7 5 19 1 21 22 8 26 4 8\n" +
                "21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
                "70 30 3 11 13 1 3 3 22 24 17 24 29 6 26 24 11 30 5 20 30 7 26 17 16 17 12 5 6 28 12 10 12 28 15 8 19 4 4 30 27 10 6 7 17 20 16 5 25 30 2 15 0 13 29 6 22 13 9 18 1 18 29 13 25 23 17 29 1 4 24 25 18\n" +
                "49 13 2 13 29 10 8 28 17 2 14 13 9 5 28 18 7 19 30 27 14 27 0 16 9 28 12 6 0 4 8 15 7 7 30 26 14 26 21 1 18 30 16 4 4 18 16 0 27 9 16 20\n" +
                "42 8 7 18 18 27 17 21 17 17 17 17 17 18 18 25 27 18 19 10 15 18 18 6 13 17 26 30 18 18 18 20 24 18 29 17 8 28 18 18 14 18 17 17 16\n" +
                "7 6 0 23 27 30 24 3 24 28\n" +
                "22 0 2 17 1 15 27 16 25 27 30 20 0 9 10 25 25 4 19 28 4 21 29 18 30\n" +
                "24 0 0 18 4 27 28 14 26 1 26 6 12 23 18 5 9 7 12 27 5 20 30 17 2 24 19\n" +
                "77 76 1 6 24 25 25 27 24 20 12 26 22 17 21 2 17 16 16 8 27 10 3 15 10 6 15 7 9 19 13 27 5 4 2 16 5 18 22 22 10 13 5 27 9 26 24 23 15 20 5 14 19 16 15 23 0 22 9 23 12 12 9 20 17 3 25 17 27 25 26 12 27 21 14 21 27 28 23 7\n" +
                "7 1 2 23 2 19 8 15 3 7\n" +
                "65 0 1 14 7 4 21 29 20 11 8 4 2 22 18 12 21 27 6 13 23 7 30 24 9 22 23 17 25 26 5 26 10 10 25 20 16 15 19 19 21 26 18 0 28 16 21 2 27 28 20 28 28 20 2 27 19 0 17 30 7 23 25 7 30 18 28 8\n" +
                "67 67 9 6 16 8 15 2 27 17 6 24 21 7 14 8 12 12 7 24 23 21 4 20 16 23 4 6 22 17 21 25 17 20 13 27 27 9 3 9 22 19 10 22 15 14 26 10 17 23 10 9 24 24 7 5 16 19 20 4 20 17 15 12 8 25 18 26 18 21\n" +
                "87 0 6 24 29 0 4 4 19 30 20 13 28 13 16 17 2 17 1 11 11 14 17 1 16 3 21 9 3 7 29 23 5 27 5 18 24 11 23 28 5 16 27 16 2 19 12 30 0 7 8 12 9 29 26 15 23 0 29 13 11 4 4 16 30 25 7 7 8 11 4 10 4 25 0 28 8 27 18 3 14 0 19 13 10 16 23 8 30 15\n" +
                "9 0 4 2 23 18 28 5 1 22 20 3\n" +
                "13 5 0 4 12 6 9 16 24 7 2 22 6 18 1 27\n" +
                "79 7 2 14 19 14 24 19 1 13 12 0 26 11 22 20 22 22 1 30 8 17 17 10 19 20 18 26 30 5 6 26 15 29 28 11 22 29 0 30 22 23 23 19 17 3 0 24 20 6 23 15 4 27 25 20 21 14 22 10 16 15 25 25 4 0 11 19 14 25 12 8 28 3 24 18 29 10 25 4 5 21\n" +
                "1 0 4 27\n" +
                "22 22 0 17 7 8 23 11 12 15 11 20 28 16 9 8 21 9 5 13 20 11 20 16 24\n" +
                "78 20 4 15 23 3 22 29 29 24 22 19 9 27 16 25 29 1 22 24 0 19 5 2 23 4 14 23 18 10 29 24 6 28 9 8 12 9 27 22 16 10 12 1 7 5 9 7 19 21 26 2 18 3 6 2 0 6 2 25 27 1 5 19 3 24 23 8 22 13 26 14 5 24 25 9 26 26 21 30 17\n" +
                "81 81 6 23 8 28 2 21 10 25 26 12 20 12 3 26 15 24 5 15 23 14 20 2 17 9 24 17 26 9 26 26 18 13 4 17 18 14 3 19 24 16 18 14 19 8 12 18 6 10 6 13 16 9 24 13 9 6 18 21 23 10 19 26 15 28 19 7 12 11 16 4 13 28 9 5 26 7 16 3 8 23 18 21\n" +
                "77 11 10 26 26 26 26 27 19 22 29 17 26 27 26 26 26 19 29 22 7 10 26 26 27 26 27 16 2 26 9 30 27 27 27 26 26 14 8 27 2 27 25 26 27 13 26 2 26 26 27 2 29 8 2 2 25 27 12 26 9 27 26 27 26 27 26 27 27 26 27 26 5 14 3 26 27 27 16 15\n" +
                "68 15 4 26 22 16 2 20 13 22 16 4 6 28 30 10 25 8 11 8 17 14 9 29 12 15 28 12 27 23 7 9 9 18 29 9 28 0 30 1 1 8 19 3 1 29 1 3 16 9 27 19 10 0 20 29 0 18 30 5 1 22 13 9 29 2 8 28 17 28 1\n" +
                "63 32 7 28 10 29 0 25 28 0 4 13 26 30 17 26 12 7 26 24 20 2 21 12 5 27 21 1 22 24 3 19 2 3 6 5 21 0 25 16 30 30 12 27 26 22 29 0 15 19 10 14 19 19 18 28 29 10 27 27 25 25 21 11 0 13\n" +
                "98 29 5 7 5 3 3 7 10 14 12 15 5 10 20 19 25 23 1 4 17 11 8 29 29 9 15 20 3 3 20 14 12 20 19 27 3 18 16 20 3 8 25 20 21 7 16 28 11 11 7 10 27 25 30 0 3 13 18 8 15 11 29 12 26 0 25 22 30 4 0 6 23 11 19 1 5 0 10 30 26 27 6 25 12 0 23 7 24 10 17 3 28 24 13 2 24 3 13 1 16\n" +
                "32 8 8 7 29 1 9 15 8 19 28 22 12 16 5 2 17 21 12 3 23 15 22 4 20 9 15 12 11 2 15 6 2 14 11\n" +
                "90 19 2 8 10 2 0 2 0 2 10 3 3 3 21 17 2 2 25 3 19 4 2 3 3 30 2 1 3 3 2 12 2 15 2 2 9 29 3 29 3 2 8 18 0 2 8 2 3 2 3 8 3 27 2 8 24 2 2 0 2 30 23 2 24 29 16 30 2 1 3 3 6 29 2 14 19 20 3 3 2 2 4 2 3 5 23 15 3 3 2 2 4\n" +
                "51 51 10 6 17 2 22 9 12 6 14 16 13 24 27 22 2 24 6 18 4 6 27 27 2 13 25 27 26 6 17 23 9 10 27 8 13 9 22 14 16 26 11 17 5 13 21 18 8 13 6 14 8 14\n" +
                "21 5 0 27 17 15 29 13 14 3 29 8 4 14 24 30 7 29 5 5 4 20 24 29\n" +
                "85 8 8 14 30 11 16 17 11 5 21 2 15 5 23 9 17 27 0 24 11 15 7 8 24 8 29 27 9 28 3 2 1 14 14 22 10 2 8 6 28 25 0 26 14 10 1 26 15 24 7 9 1 4 14 6 13 20 29 5 25 11 9 22 19 14 4 8 28 6 18 26 5 19 26 6 28 14 16 26 26 2 30 28 6 13 14 22\n" +
                "45 45 1 5 26 21 28 5 2 7 12 26 14 7 14 4 14 23 24 18 27 15 2 27 26 13 5 26 16 28 5 21 24 8 10 15 22 8 18 21 2 15 11 11 17 24 26 21\n" +
                "60 0 10 20 2 27 13 16 10 19 27 16 1 13 24 13 2 8 1 23 1 6 25 9 14 26 27 25 6 1 16 2 7 24 6 28 17 1 25 19 11 12 15 30 25 25 1 22 21 26 9 9 4 22 20 21 0 25 13 5 21 9 28\n" +
                "91 18 3 30 5 9 6 5 14 6 23 5 5 6 22 30 5 25 6 5 3 6 4 5 20 17 18 5 25 19 5 6 5 6 6 13 6 5 5 16 5 6 15 25 29 6 12 29 5 5 5 24 2 6 6 5 6 22 5 5 8 16 6 5 5 6 5 5 5 7 9 26 5 8 5 10 2 5 5 5 1 6 0 5 0 30 6 22 6 5 30 6 28 30\n" +
                "24 15 3 7 22 21 7 14 8 8 23 30 13 19 1 30 8 14 26 8 15 0 26 27 0 8 1\n" +
                "6 6 8 15 20 28 5 21 10\n" +
                "37 14 5 20 5 1 23 9 30 21 9 14 1 22 15 17 16 27 6 21 10 0 0 27 8 8 17 18 3 18 6 25 12 20 29 18 19 19 9 13\n" +
                "13 12 9 15 2 15 3 25 0 24 25 10 6 26 25 12\n" +
                "41 7 2 7 15 14 30 24 27 29 6 5 26 30 25 28 27 1 6 6 14 15 8 19 16 6 7 30 25 30 11 21 0 25 7 7 11 5 3 25 10 1 24 11\n" +
                "86 4 6 15 14 30 11 30 9 30 20 14 14 14 30 13 19 2 12 14 7 27 15 14 10 14 14 14 28 14 14 14 15 14 19 28 14 14 4 23 7 12 14 15 23 12 14 14 15 4 23 15 19 8 15 15 15 15 14 15 17 10 7 14 14 15 20 24 15 26 15 14 28 15 14 16 3 2 15 14 15 10 14 14 14 14 15 7 14\n" +
                "77 70 10 6 29 7 18 22 25 27 7 23 24 13 13 21 15 23 14 15 7 15 17 17 0 19 3 21 2 15 1 23 26 13 19 1 4 4 10 12 29 20 13 22 22 29 15 16 15 5 2 10 18 9 21 26 20 4 11 7 25 23 23 27 4 20 19 14 13 22 22 0 27 15 11 15 22 24 25 18\n" +
                "29 10 1 17 29 6 30 25 8 27 28 9 8 15 15 29 10 2 3 24 1 23 23 10 28 24 9 21 24 21 21 27\n" +
                "21 8 9 23 24 15 10 22 24 23 23 24 24 23 21 0 17 23 24 24 1 28 9 8\n" +
                "44 0 7 9 1 24 4 9 2 15 25 30 30 5 3 24 15 26 26 1 7 18 2 6 3 27 8 10 6 2 4 30 10 0 25 16 21 26 23 13 20 19 12 27 24 5 12\n" +
                "24 0 10 0 13 15 21 10 20 30 2 22 25 30 2 2 25 11 18 10 15 19 26 0 11 13 1\n" +
                "55 14 8 30 8 15 3 2 16 19 22 8 16 8 26 25 19 28 12 12 1 18 21 12 2 25 3 28 28 15 27 11 2 8 19 18 12 10 29 12 10 27 0 20 26 28 26 17 18 10 28 30 4 17 22 23 30 6\n" +
                "49 28 2 17 24 17 8 21 18 2 28 29 9 7 24 9 15 2 9 13 30 28 0 23 29 23 9 3 26 1 6 6 5 11 4 20 2 19 5 25 18 29 11 0 9 24 13 8 14 12 22 11\n" +
                "49 10 3 8 12 20 3 5 12 6 30 5 6 6 5 22 22 6 6 28 15 30 5 5 6 20 3 5 6 5 6 5 8 5 6 21 12 5 5 6 18 5 28 5 20 24 23 26 11 6 6 25\n" +
                "41 5 10 5 14 7 7 12 13 26 17 27 18 21 0 28 8 12 7 27 10 11 28 12 11 29 19 12 2 28 9 26 9 0 1 14 10 20 19 5 24 9 15 14\n" +
                "14 0 2 3 3 3 22 3 3 5 30 3 3 0 10 3 3\n" +
                "44 44 0 21 27 19 3 26 9 24 8 27 8 21 16 18 11 20 11 10 21 8 20 8 5 11 22 20 19 2 10 11 16 11 25 9 8 7 13 21 19 17 7 14 27 10 3\n" +
                "9 0 9 5 9 1 8 30 2 4 14 30\n" +
                "93 18 7 17 24 17 18 18 21 18 17 17 17 17 21 18 17 17 17 18 18 17 18 3 18 19 17 17 1 18 28 27 27 9 17 10 10 17 17 17 17 17 18 17 16 12 18 17 18 15 17 15 27 21 13 26 5 24 18 17 24 24 15 14 18 22 17 18 17 17 11 16 1 18 14 18 3 8 9 18 18 25 19 17 16 17 18 3 10 17 6 17 17 18 8 30\n" +
                "54 16 6 14 14 14 18 15 12 29 10 14 28 15 15 14 25 28 14 23 8 14 15 14 2 15 15 28 14 15 22 14 14 14 20 16 14 18 27 15 18 20 14 15 19 18 13 16 9 1 30 14 15 14 24 15 28\n" +
                "51 3 2 21 11 10 1 15 10 20 22 8 11 3 29 21 25 24 10 28 23 8 20 3 2 29 7 0 16 24 24 21 9 2 29 16 4 27 4 28 5 9 23 23 2 13 22 25 3 0 15 8 18 5\n" +
                "66 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0\n" +
                "7 0 2 5 1 15 3 28 2 6\n" +
                "8 0 5 29 0 25 15 28 27 28 22\n" +
                "62 15 5 17 27 13 11 12 14 11 26 11 14 11 16 14 17 11 1 12 11 6 11 24 1 29 15 9 12 10 2 14 12 6 10 22 19 12 6 0 12 11 11 11 12 26 11 11 11 11 28 21 11 11 7 9 6 11 12 1 19 21 30 22 11\n" +
                "58 28 9 7 24 24 14 24 23 25 24 23 24 24 24 20 23 23 16 23 28 4 23 18 23 24 24 24 30 24 24 23 23 17 24 23 23 16 18 27 29 1 28 24 23 23 10 19 23 24 27 23 23 21 23 23 13 23 23 17 9\n" +
                "1 0 8 20\n" +
                "96 47 1 24 22 14 18 4 27 30 1 23 1 1 12 1 3 7 1 5 6 4 22 13 30 4 28 15 29 24 6 16 22 21 25 30 9 17 6 18 1 30 28 30 2 18 27 3 26 19 27 26 11 0 15 15 4 7 8 6 22 18 24 5 21 9 23 0 21 15 25 10 29 28 19 21 24 28 21 10 15 13 27 29 8 7 29 3 3 5 6 22 22 5 25 2 26 0 13\n" +
                "64 25 5 20 12 11 12 11 12 18 5 12 21 11 27 24 11 26 12 12 12 11 12 10 12 23 18 11 4 27 17 12 11 20 21 2 0 12 12 13 11 11 11 12 24 12 27 10 14 24 17 15 15 11 5 11 26 11 23 11 11 12 12 12 27 11 26\n" +
                "75 7 9 23 25 19 29 21 23 17 24 24 13 23 1 24 27 24 24 23 23 30 5 23 9 23 14 8 1 14 24 24 10 24 22 23 26 16 24 24 24 27 29 24 24 24 8 24 1 6 23 23 5 23 25 23 23 24 8 24 14 23 7 25 24 1 23 23 21 23 16 10 24 1 23 23 24 24\n" +
                "75 45 1 3 14 27 14 21 10 24 16 9 16 24 6 22 22 30 3 30 8 15 15 23 30 25 2 23 27 7 28 14 13 19 9 30 23 22 9 12 27 1 8 3 7 9 8 16 23 19 15 13 24 8 8 24 5 2 15 26 18 8 0 12 3 27 15 6 6 8 4 30 11 13 30 8 7 27\n" +
                "61 47 9 7 25 27 16 8 17 1 18 13 21 23 13 4 9 15 26 3 27 23 24 22 10 0 30 12 18 12 19 27 11 28 3 23 30 17 28 7 26 18 7 21 7 17 13 16 26 8 8 15 4 12 24 16 15 29 14 6 25 10 20 30\n" +
                "80 54 1 25 29 17 30 5 26 6 23 9 9 16 0 22 3 13 1 5 10 16 3 2 8 3 17 24 23 18 21 22 6 21 10 12 4 24 14 30 22 29 30 5 1 4 2 22 20 6 22 27 12 5 5 29 16 8 30 18 2 3 30 5 2 0 7 15 5 2 28 4 4 28 30 22 13 28 12 16 4 17 5\n" +
                "76 40 7 25 25 12 18 0 22 4 12 24 1 12 21 16 20 23 23 30 27 6 23 0 1 7 8 28 10 29 5 22 22 2 23 28 14 29 18 0 14 23 13 8 18 28 12 25 14 18 7 16 8 4 25 24 12 6 2 1 7 24 8 19 19 7 24 21 10 9 6 10 4 12 22 3 30 22 10\n" +
                "15 8 9 23 26 23 23 0 24 24 23 14 23 24 24 23 21 23\n" +
                "17 1 8 9 21 20 20 20 21 21 20 21 21 20 20 3 8 12 21 20\n" +
                "11 0 2 10 10 14 4 2 16 22 4 2 18 20\n" +
                "31 1 7 20 3 6 7 29 6 1 10 15 4 16 25 7 1 7 30 19 15 26 13 24 1 14 19 18 21 2 3 20 5 3\n" +
                "11 2 6 15 14 17 14 26 14 14 20 15 2 15\n" +
                "42 0 10 30 10 21 7 0 24 26 19 2 11 21 14 1 28 4 10 16 20 28 2 11 14 5 14 28 6 8 6 28 0 22 13 1 1 9 27 17 22 16 28 29 18\n";

        String[] lines = input.split("\n");
        int T = Integer.parseInt(lines[0]);
        for (int i = 1; i <= T; i++) {
            String line = lines[i];
            String[] items = line.split(" ");
            int n = Integer.parseInt(items[0]);
            int s = Integer.parseInt(items[1]);
            int p = Integer.parseInt(items[2]);

            int[] t = new int[n];
            for (int j = 0; j < n; j++) {
                t[j] = Integer.parseInt(items[3 + j]);
            }

            int solution = solve(n, s, p, t);
            System.out.println("Case #" + i + ": " + solution);
        }
    }
}
