#include <stack>
#include <string>
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_map>


using namespace std;

const int MAXN = 100 + 10;
int A[MAXN];

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

	sort(A, A + n);
	int cnt = 0;
	int j = 0;
	while (x > 0) {
		if (j == n) break;
		if (x >= A[j]) {
			x -= A[j];
			j++;
			cnt++;
		}
		else {
			break;
		}
	}
	if (x > 0) cnt--;
	cout << cnt << endl;
	return 0;
}