#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





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 ++){
		if(x >= v[i]){
			ans++;
			x -= v[i];
		}
	}
	if(x > 0) ans--;
	ans = max(ans , 0LL);
	cout<<ans<<endl;
}