W#include <iostream>
#include <vector>
using namespace std;

int N;
long long x;
int main() {
    while (cin >> N >> x) {
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        sort(a.begin(), a.end());
        int res = 0;
        for (int i = 0; i < N; ++i) {
            if (x >= a[i]) ++res, x -= a[i];
            else break;
        }
        cout << res << endl;
    }
}
