var
cl:array [1..3]of longint;
i,n,m,l,max,minbu,minl,lo:longint;
ans:array [0..500]of longint;
procedure init;
var i1:integer;
begin
readln(n,m);
for i:=1 to 3 do
begin
readln(cl[i]);
if (minl=0) or (minl>cl[i]) then minl:=cl[i];
end;
readln(l);
end;
procedure dps(bu:longint);
var i2:longint;
begin
max:=0;
if ans[bu-1]+minl>m then exit
else
begin
for i:=1 to 3 do
begin
if (ans[bu-1]+cl[i]>max) and (ans[bu-1]+cl[i]<m) then
begin
ans[bu]:=ans[bu-1]+cl[i];
max:=ans[bu];
lo:=bu;
end;
end;
dps(bu+1);
end;
end;
procedure dc(zl:longint);
var v1,v2:longint;
begin
v1:=lo;
while ans[v1]<>m do
if m-ans[v1]<zl then writeln('No solution.')
else
begin
ans[v1]:=ans[v1]+zl;
inc(lo);
end;
end;
begin
assign(input,'wood.in');
reset(input);
assign(output,'wood.out');
rewrite(output);
init;
dps(1);
dc(l);
writeln(lo);
close(input);
close(output);
end.