program tickets;
var
n,f,i,j,t,m,sum:longint;
a:array[1..10000] of longint;
begin
assign(input,'tickets.in');
reset(input);
assign(output,'tickets.out');
rewrite(output);
readln(n,f);
for i:=1 to n do read(a[i]);
for i:=1 to n-1 do
for j:=i+1 to n do
if a[i]>a[j] then begin t:=a[i]; a[i]:=a[j]; a[j]:=t; end;
sum:=0;
for i:=1 to n do
begin
if sum+a[i]<=f then begin sum:=sum+a[i]; m:=m+1; end;
end;
writeln(m);
close(input);
close(output);
end.