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

int main()
{
	int n, m = 0;
	long x;
	long a[100];

	cin >> n >> x;

	for (int i = 0; i < n; i++)
		cin >> a[i];

	sort(a, a + n);

	while (x - a[m] >= 0 && m < n - 1) {
		x -= a[m];
		m++;
	}

	if (x == a[m])
		m = n;

	cout << m << endl;

	return 0;
}