#include <iostream>
#include <algorithm>

using namespace std;

int a[105];

int main ()
{
int n, x;
cin >> n >> x;
for(int i = 0 ; i < n ; ++i){
	cin >> a[i];
}
sort(a, a + n);
int sol = 0;
for(int i = 0 ; i < n ; ++i){
	if(x - a[i] < 0)
		break;
	x -= a[i];
	sol++;
}
sol -= (x > 0 && sol == n);
cout << sol << endl;

return 0;
}
