#include<iostream>
#include<algorithm>
#include<string>
#include<set>
#include<math.h>
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 sum=0, count=0;
    while(sum<x){
        sum+=a[count];
        //cout << a[count] << " " << sum << " " << count << endl;
        count++;
    }
    count << count-1 << endl;
    return 0;
}
