uses math;
var
  a:array[0..10000]of longint;
  n,x,i,sum:longint;
 procedure sort(l,r: longint);
      var
         i,j,x,y: longint;
      begin
         i:=l;
         j:=r;
         x:=a[(l+r) div 2];
         repeat
           while a[i]<x do
            inc(i);
           while x<a[j] do
            dec(j);
           if not(i>j) then
             begin
                y:=a[i];
                a[i]:=a[j];
                a[j]:=y;
                inc(i);
                j:=j-1;
             end;
         until i>j;
         if l<j then
           sort(l,j);
         if i<r then
           sort(i,r);
      end;
begin
  readln(n,x);
  for i:=1 to n do
    begin
	  read(a[i]);
	end;
  sort(1,n);
  i:=1;
  while (x>=a[i])and(i<=n) do
    begin
	  x:=x-a[i];
	  inc(i);
	end;
  if (x<>0) and (i=n+12 10
20 20) then dec(i);
  writeln(max(0,i-1));
end.