<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function arrayIn(){
		$buf = explode(" ", fgets(STDIN));
		return $this->killNewLine($buf);
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->arrayIn();
	
		$n = $s[0];
		$x = $s[1];

		$c = $this->arrayIn();

		sort($c);

		$ans = 0;
		foreach($c as $k => $v){
			if(0 <= ($x - $v)){
				$x -= $v;
				$ans++;
			}else{
				break;
			}
		}
		unset($k);
		unset($v);

		echo $ans . "\n";

	}
}
?>