use v5.18; # strict say state
use warnings;
use List::Util qw(reduce first max min sum0);

chomp (my ($n, $x) = split / /, <STDIN>);
chomp (my @a = split / /, <STDIN>);
@a = sort { $a <=> $b } @a;
my $ans = 0;
for my $i (0..($n-1)) {
  if ($x >= $a[$i]) {
    $x -= $a[$i];
    $ans++;
  } else {
    last;
  }
}
$ans-- if $x > 0 && $ans > 0;
say $ans;