#include <bits/stdc++.h>
using namespace std;
using ll = long long;


int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll a[101];
    ll n, x; cin >> n >> x;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n, greater<>());

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (x >= a[i]) {
            x -= a[i];
            cnt++;
        }
    }

    if (x && cnt) {
        cnt--;
    }


    cout << cnt << '\n';

    return 0;
}
