function getLines(input){
	return input.split("\n").map((s)=>s.trim())
}
function parseLine(line){
	return line.split(" ").map((s)=>s.trim());
}
function parseLineToInt(line){
	return line.split(" ").map((s)=>parseInt(s.trim()));
}
// parameter "input" gets all data
function Main(input) {
	// the first line is assigned to input[0], the second line is assigned to input[1] similarly.	
	input = getLines(input).map(parseLineToInt);
	var a = input[1];
	var n=input[0][0];
	var x=input[0][1];
	a.sort((z,t)=>(z-t));
	i=0;
	var ans =0;
	while(x>0 && i<n){
		if(x>=a[i]){
			x-=Math.min(x,a[i++]);
			ans++;
		}else{
			break;
		}
	}
	if(x>0 && i==n)
		ans--;
	console.log(ans);
}
// Don't edit this line!
//Main(require("fs").readFileSync(__dirname+'/in.txt', "utf8"));
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));
