var
	a:array[0..200] of longint;
	i,j,t,n,ans:longint;
begin
	read(n,ans);
	for i:=1 to n do read(a[i]);
	for i:=1 to n-1 do
		for j:=1 to n-i do
			if a[j]>a[j+1] then
			begin
				t:=a[j]; a[j]:=a[j+1]; a[j+1]:=t;
			end;
	i:=1;
	while (ans>=a[i]) and (i<=n) do
	begin
		ans:=ans-a[i];
		inc(i);
	end;
	if (i=n+1) and (ans>0) then dec(i);
	writeln(i-1);
end.