#include <iostream>
#include <algorithm>

using namespace std;
int main(){
	int n,x,i,a[1000],ans = 0,k = -1;
	cin >> n >> x;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]<=x){
			x -= a[i];
			ans++;
			k = i;
		}
	}
	if(k==n-1 && x>0){
		ans--;
	}
	cout << ans << endl;
}