#include <iostream>
#include <algorithm>
using namespace std;

int main() {
	int n, x, a[110], cnt = 0;
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> a[i];

	sort (a, a + n);
	
	for (int i = 0; i < n; i++) {
		if (x >= a[i]) {
		cnt++;
		x -= a[i];
		}
	}

	if (cnt == n && x > 0) cnt--;

	cout << cnt << endl;
	return 0;
}