#include <bits/stdc++.h>
using namespace std;

int main(){
	
	int n, x;
	cin >> n >> x;
	vector<int> v(n);
	for (int& e: v){
		cin >> e;
	}
	sort(v.begin(), v.end());
	int count = 0;
	for (int e: v){
		x = x - e;
		if (x<0) break;
		count++;
	}
	if (x>0) count--;
	cout << count;
}

