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 ($sum, $cnt, $j) = (0, 0, 0);
for my $i (0..$n-1) {
  $sum += $a[$i];
  $cnt++;
  $j = $i;
  last if $sum >= $x;
}
$cnt-- if $sum < $x && $j == $n - 1;
$cnt-- if $j < $n - 1;
say $cnt;