import java.util.Scanner;
import java.io.*;
class dance
{
  public static void main (String[] args) throws IOException
  { 
    File    inputData = new File("B-small-attempt0.in");
	File 	outputData= new File("Boutput.txt");
    Scanner scan = new Scanner( inputData );
	PrintStream print= new PrintStream(outputData);
    
	int t;
	int n,s,p,pi;
	t= scan.nextInt();
	for(int i=1;i<=t;i++)
	{
	n=scan.nextInt();	s=scan.nextInt();	p=scan.nextInt();
	int supTrip=0, notsupTrip=0;
	
	for(int j=0;j<n;j++)
	{
		pi=scan.nextInt();
		if(pi>(3*p-3))
		notsupTrip++;
		else if((pi>=(3*p-4))&&(pi<=(3*p-3))&&(pi>p))
		supTrip++;
	}
	
	if(s<=supTrip)
	notsupTrip=notsupTrip+s;
	else if(s>supTrip)
	notsupTrip= notsupTrip+supTrip;
	print.println("Case #"+i+": "+notsupTrip);
	}
  }
}
package com.codejam2012.qualificationround;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;

public class B {

	public static int nTest;
	public static int nGoogler;
	public static int nSurprise;
	public static int threshold;
	public static int[] scores;
	public static int nHaveHighScore;
	public static int maxScore;
	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(new File("input.txt"));
		FileWriter writer = new FileWriter(new File("output.txt"));
		
		nTest = scanner.nextInt();
		
		for (int i=1;i<=nTest;++i) {
			nHaveHighScore = 0;
			nGoogler = scanner.nextInt();
			nSurprise = scanner.nextInt();
			threshold = scanner.nextInt();
			scores = new int[nGoogler];
			for (int j=0;j<nGoogler;++j) {
				scores[j] = scanner.nextInt();
				
				if (scores[j] % 3 == 0) {
					maxScore = scores[j] / 3;
					if (maxScore >= threshold) {
						nHaveHighScore++;
					}
					else if (nSurprise > 0 && maxScore+1 >= threshold && maxScore-1 >= 0) {
						nHaveHighScore++;
						nSurprise--;
					}
				}
				else if (scores[j] % 3 == 1) {
					maxScore = scores[j] / 3 + 1;
					if (maxScore >= threshold) {
						nHaveHighScore++;
					}
				}
				else if (scores[j] % 3 == 2) {
					maxScore = scores[j] / 3 + 1;
					if (maxScore >= threshold) {
						nHaveHighScore++;
					}
					else if (nSurprise > 0 && maxScore+1 >= threshold && maxScore-1 >= 0) {
						nHaveHighScore++;
						nSurprise--;
					}
				}
			}
			writer.write("Case #" + i + ": " + nHaveHighScore);
			if (i < nTest) {
				writer.write("\n");
			}
			writer.flush();
		}		
		writer.close();
	}
}
