#include"bits/stdc++.h"
using namespace std;
int main(){
	int n,s;
	cin>>n>>s;
	vector<int> x;
	for(int i=0;i!=n;++i){
		int m;
		cin>>m;
		x.push_back(m);
	}
	sort(x.begin(),x.end());
	int i=0;
	for(;i!=n;++i){
		if(i==n-1){
			if(x[i]==s)
				++i;
			break;
		}
		if(x[i]>s)
			break;
		s-=x[i];
	}
	cout<<i;
}

