<?php

$input = trim(fgets(STDIN));
$input = explode(' ', $input);

$n = (int)$input[0];
$x = (int)$input[1];

$input = trim(fgets(STDIN));
$input = explode(' ', $input);

$c = array_map(function ($x){
    return (int)$x;
}, $input);

asort($c);

$count = 0;
foreach($c as $item){
    $x -= $item;
    if (0 <= $x)
        $count++;
}

echo $count;
echo "\n";
?>
