#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void){
   int n,x;
   cin >> n >> x;
   vector<int> a(n);
   int sum = 0;
   int ans = n - 1;
   for(int i = 0;i < n;i++){
       cin >> a[i];
       sum += a[i];
   }
   sort(a.begin(),a.end,greater<int>());
   if(sum == x){
       cout << n << endl;
   }else if(sum < x){
       cout << n - 1 << endl;
   }else{
       while(sum > x && ans >= 0){
           sum -= a[ans];
           ans--;
       }
       cout << ans << endl;
   }
}
