#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
int main(){
	ll n,x;
	cin >> n >> x;
	ll a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	ll sum=0;
	rep(i,n){
		sum+=a[i];
		if(sum>x){cout << i << endl;return 0;}
	}
  	if(sum==x)cout << n << endl;
  else cout << n-1 << endl;
}
