#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x,ans=0,i;
	cin>>n>>x;
	vector<int> a;
	int A;
	for(i=0;i<n;i++){
		cin>>A;
		a.push_back(A);
	}
	sort(a.begin(),a.end());
	for(i=0;i<n&&x>=a[i];i++,ans++) x-=a[i];
	if(ans==n&&x!=0) cout<<ans-1<<endl;
	else cout<<ans<<endl;
	return 0;
}
