#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define for1(i, m, n) for(int i = m;i < n;i++)
#define ll long long
#define endl '\n'
using namespace std;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll int n, x;
    cin >> n >> x;
    ll int a[100];
    rep(i, n) {
        cin >> a[i];
    }
    sort(a, a+n);

    ll int sum = 0, m = 0;
    rep(i, n) {
        sum += a[i];
        if (sum <= x) {
            m++;
        }
        if (sum == x) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    cout << max(m - 1, 0) << endl;
	return 0;
}