#include<iostream>
#include<vector>
using namespace std;
int main() {
    long long N,x,sumv=0;
	cin >> N >> x;
	vector<int> vec(N);
	for (auto& v : vec){cin >> v;sumv += v;}

    if (sumv < x) {cout << N-1 << endl;} 
    else if (sumv == x) {cout << N << endl;}
    else {
        sort(vec.begin(),vec.end());
        for (int i=0;i<N;i++) {
            if (x >= vec[i]) { x -= vec[i]; }
            else { cout << i << endl; break; }
        }
    }
    return 0;