my $input = <STDIN>;
chomp $input;

my ($N, $x) = split /\s/, $input;

$input = <STDIN>;
chomp $input;

my $a = [ sort split /\s/, $input ];

my $cnt = 0;
for (@$a) {
    $x -= $_;
    last if $x < 0;
    $cnt++;
}

print $cnt;
