/****JMD****/
/*
Nagendra Jha-4096
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define f(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll(a.size())

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    ll n,x;
    cin>>n>>x;

    ll a[n];
    f(i,n) cin>>a[i];

    sort(a,a+n);

    ll ans=0;

    f(i,n)
    {
        if(a[i]<=x)
        {
            x-=a[i];
            ans++;
        }
    }
    if(x) ans--;

    cout<<max(0,ans);

    return 0;
}
