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


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

	}
	sort(a, a + n);
	for (int i = 0; i < n-1; i++) {
		if (x < a[i])break;
		else {
			k++;
			x -= a[i];
		}
	}
	if (x == a[n - 1])k++;
	cout << k << endl;
    return 0;
}