import std.array;
import std.range;
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;

void main()
{
	while(true) {
		string[] input = split(chomp(readln()));	
		int N = to!int(input[0]);
		int M = to!int(input[1]);
		if(N==0&&M==0) break;
		

		int[] inp = [0];
		auto app = appender(inp);

		for(int i=0; i<N; i++) {
			input = split(chomp(readln()));	
			app.put(to!int(input[0]));
		}

		writeln(inp.length);
		inp = app.data;

		for(int i=0; i<=N; i++)
		for(int j=0; j<=N; j++)
			app.put(inp[i] + inp[j]);

		auto sorted = array(uniq(sort(app.data)));	
		auto r = assumeSorted(sorted);

		int res;
		for(int i=0; i<sorted.length; i++)
		{
			if(sorted[i] > M) break;
			res = max(res, sorted[i] + reduce!(max)(array(r.lowerBound(M-sorted[i]))));
		}

		writeln(res);
	}
}