#include "bits/stdc++.h"
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int main(){
        int n,x,ans=0;
        cin>>n>>x;
        int a[n]={0};
        rep(i,0,n)cin>>a[i];
        sort(a,a+n);
        int i=0;
        while(x>=0){
                x-=a[++i];
                ans++;
        }
        (ans)?ans--:;
        (a[n-1])?cout<<ans<<endl:cout<<n-1<<endl;
        return 0;
}
