#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define F first
#define S second
#define mt make_tuple
#define pb push_back


int readint(){
	char c;
	int a = 0;
	while(!( c >= '0' && c <= '9')) c = getchar();
	while(c >= '0' && c <= '9') a = 10*a + (c - '0') , c = getchar();
	return a;
}



int32_t main(){
	int n , x;
	cin>>n>>x;
	vector<int>v(n);
	for(int i = 0 ; i < n; i ++) cin>>v[i];
	sort(v.begin() , v.end());
	int ans = 0;
	for(int i = 0 ; i < n;i ++){
		int r = min(x , v[i]);
		if(r == v[i]) ans++;
		x -= r;
	}
	if(x > 0) ans--;
	cout<<ans<<endl;
}