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

using ll    = long long;
using ull   = unsigned long long;
using veci  = vector<int>;
using vecll = vector<ll>;
#define eps (1e-7)
#define inf (1e9)
#define pi  (acos(-1))
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define rep(i,n) for(int i= 0;i<(int)(n);++i)
#define pb push_back

int gcb(int a,int b){return ((b == 0)? a : gcb(b,a%b));}
int gcd(int a,int b){return (a*b) / gcb(a,b);}

int main(){
    int n,ans = 0;
    ll x;
    vecll a;
    cin >> n >> x;
    rep(i,n){
        ll tmp;
        cin >> tmp;
        a.pb(tmp);
    }
    sort(a.begin(),a.end());
    rep(i,n){
        if(x >= a[i]){
            x -= a[i];
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}
