#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N, x;

	cin >> N >> x;

	int distributing;
	vector<int> distrubiton;
	if (N <= 100)
	{
		for (int count(0); count < N; ++count)
		{
			cin >> distributing;
			distrubiton.push_back(distributing);
		}
	}

	sort(distrubiton.begin(), distrubiton.end());

	// do addition
	int tempsum(0);
	for (auto each : distrubiton)
		tempsum += each;

	int sum(0), counting(0), total = x, alot(0);
	for (auto each : distrubiton)
	{
		if (total >= each && total <= pow(10, 9))
		{
			if (each == *(distrubiton.end() - 1) && total > each)
			{
				break;
			}
			++counting;
			total -= each;
		}
	}

	if (counting > 0)
		cout << counting;
	else
		cout << 0;

	return 0;
}