#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,x;
    int a[110];
    cin>>N>>x;
    for(int i=0;i<N;i++)cin>>a[i];
    sort(a,a+N);
    int res=0;
    while(x>=a[res]&&res<N-1){
        x-=a[res];
        res++;
    }
    if(x==a[N-1])cout<<res+1<<endl;
    else cout<<res<<endl;
    return 0;
}
