#include <iostream> 

using namespace std;

#define rep(i, a, n) for (int i = a; i < (n); ++i)

int main()
{
	int n, x;
	cin >> n >> x;
	int a[n];
	int count = 0;
	
	rep(i, 0, n) cin >> a[i]］
	
	sort(a.begin(), a.end());
	
	rep(i, 0, n)
	{
		if (a[i] <= x) 
		{
			if (i == (n - 1))
			{
				if (a[i] == x) 
				{
					++count;
				}
			}
			else
			{
				++count;
				x -= a[i];
			}
		}
	}
	cout << count << endl;
}