#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=998244353;
const LL LINF=1LL<<62;
const LL INF=1<<17;
   

int main(){
    int N;
    LL x;
    cin >> N >> x;
    LL a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(ALL(a));
    int ans=0;
    for(int i=0;i<N;i++){
        x-=a[i]; 
        if(x>=0) ans++;
        else break;
    } 
    if(x>0) ans--;
    cout << ans << endl;
    return 0;
}

