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

int main() {
	int n, x;
	int a[101];
	cin>>n>>x;
	for (int i=0; i<n; i++)
		cin>>a[i];
	sort(a, a+n);
	int i=0;
	while (i<n && a[i]<=x)
		x -= a[i++];
	if (i==n && x!=0)
		cout<<i-1<<endl;
	else
		cout<<i<<endl;
	return 0;
}
