#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n, x;
    cin >> n >> x;
	vector<int> v(n);
	for (int i = 0; i < n; ++i) cin >> v[i];
	sort(v.begin(), v.end());
	int sum = 0, cnt = 0;
	for (int i = 0; i < n; ++i) {
		if (sum + v[i] > x) break;
		sum += v[i];
        cnt++;
	}
	if (cnt == n && sum < x) cnt--;
	cout << cnt << endl;
}
