#include<bits/stdc++.h>
using namespace std;
 
int main(){
   int N;
   long int x;
   cin >> N >> x;
   long int count = 0;
   vector<long int> a(N);
    long int answer = 0;
   for(int i = 0; i < N; i++){
       cin >> a[i];
   }

   sort(a.begin(),a.end());

    for(int i = 0; i < N; i++){
        if(count + a[i] <= x){
        answer += 1;
        count += a[i];
        }else{
            break;
        }
    }

    if(ans == N && x - count > 0) --answer;

    cout << answer;

    return 0;
}