#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    ll now = 0;
    int ans = n;
    rep(i,n){
        now += a[i];
        if(now > x){
            ans = i;
            break;
        }
    }

    if(ans==n&&now!=x) cout << (n-1) << endl;
    else cout << ans << endl;
    return 0;
}
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int N, x;
    cin >> N >> x;
    vector<int> v(N);

    for (int i = 0; i < N; i++)
    {
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());

    int cnt = 0;
    if (x < v.at(0))
    {
        cout << 0;
    }
    else
    {
        for (int i = 0; i < N && x >= v.at(i); i++)
        {
            cnt++;
            x -= v.at(i);
        }

        if (cnt == N && x > 0)
            cnt--;

        cout << cnt;
    }
}
