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

public class Triples {
	private int [] values;
	private int surprise=-1;
	private boolean Boolsurprise;
	int maxValue=-1;

	
	public Triples (int a,int b ,int c){
		values=new int [3];
		values[0]=a;
		values[1]=b;
		values[2]=c;
	}
	public int sum(){
		return values[0]+values[1]+values[2];
	}
	
	public boolean isSurprise(){
		if(surprise==-1)
			calculateSurprise();
		return Boolsurprise;
	}
	private void calculateSurprise() {
		surprise=1;
		if(Math.abs(values[0]-values[1])>=2)
			Boolsurprise=true;
		if(Math.abs(values[0]-values[2])>=2)
			Boolsurprise=true;
		if(Math.abs(values[1]-values[2])>=2)
			Boolsurprise=true;
		
	}
	public int getMaxValue() {
		if(maxValue>0)
			return maxValue;
		int max=values[0];
		for(int i=1;i<values.length;i++)
			if(values[i]>max)
				max=values[i];
		maxValue=max;
		return maxValue;
	}
	@Override
	public String toString() {
		String s="";
		for(int i=0;i<values.length;i++)
			s+=values[i]+" ";
		if(isSurprise())
			s+="(*)";
		return s;
			
	}
}
