package problem1;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.Arrays;





public class Problem1 {

    public static void main(String[] args) throws FileNotFoundException, IOException{
        try {
             TextIO.readFile("L:\\Coodejam\\Input\\Input.txt");
        }
        catch (IllegalArgumentException e) {
              System.out.println("Can't open file ");
              System.exit(0);
         }
        
        FileOutputStream fout = new FileOutputStream("L:\\Coodejam\\Output\\output.txt");
        PrintStream ps=new PrintStream(fout);
        
        int cases=TextIO.getInt();
        int googlers=0,surprising=0,least=0;
        for(int i=0;i<cases;i++){
            int counter=0;
            googlers=TextIO.getInt();
            surprising=TextIO.getInt();
            least=TextIO.getInt();
            int score[]=new int[googlers];
            for(int j=0;j<googlers;j++){
                score[j]=TextIO.getInt();
                 }
            
            
            
            
            Arrays.sort(score);
            int temp=0;
            int sup[]=new int[surprising];
            
          for(int j=0;j<googlers && surprising>0;j++){
               if(biggestNS(score[j])<least && biggestS(score[j])==least){
                   surprising--;
                   counter++;
                }
               }
           
            for(int j=0;j<googlers;j++){
                if(surprising==0)temp=biggestNS(score[j]);
                    
                else {
                    temp=biggestS(score[j]);
                    surprising--;     
                } 
                   if(temp>=least)counter++;
           
             }
            
             ps.println("Case #"+(i+1)+": "+counter);
        }
    }
    
   static int biggestNS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-1)/3)+1;
   }
   
   static int biggestS(int x){
       if(x==0)return 0;
       if(x==1)return 1;
       return ((x-2)/3)+2;
   }
}
package at.jaki.codejam.qr2012.B;

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

public class B {

	private static final String TEMPLATE = "Case #%d: %d";

	private static final String IN = "B-small-attempt0.in";
	private static final String OUT = "B-small-attempt0.out";

	private static Scanner sc;
	private static PrintWriter pw;

	public static void main(String[] args) throws FileNotFoundException {
		sc = new Scanner(new File(IN));
		pw = new PrintWriter(new File(OUT));
		int tests = sc.nextInt();
		for (int i = 1; i <= tests; i++) {
			resolve(i);
		}
		pw.flush();
		pw.close();
	}

	private static void resolve(int TT) {
		int n = sc.nextInt();
		int s = sc.nextInt();
		int p = sc.nextInt();
		int[] scores = new int[n];
		for (int i = 0; i < n; i++) {
			scores[i] = sc.nextInt();
		}

		int total = 0;
		for (int i = 0; i < n; i++) {
			int q = scores[i] / 3;
			int r = scores[i] % 3;

			int best;
			if (r == 0) {
				best = q;
			} else {
				best = q + 1;
			}
			if (best >= p) {
				total++;
				continue;
			}

			if (best == p - 1) {
				if (s > 0 && r != 1 && scores[i] != 0) {
					total++;
					s--;
					continue;
				}
			}
		}
		pw.println(String.format(TEMPLATE, TT, total));
		System.out.println(total);

	}
}

// 4---> 2 1 1
// 4*--> 2 2 0

// 5---> 2 2 1
// 5*--> 3 1 1

// 6---> 2 2 2
// 6*--> 3 2 1

// 7---> 3 2 2
// 7*--> 3 3 1 