#include <iostream>
#include <string>
#include <list>
using namespace std;
set<string> s;
int solveMeFirst(list<int> l, int num){
    int ret = 0;
    l.sort();
    for (int i = 0; i<l.size(); i++){
         if (l.at(i) < num){
              num -= l.at(i);
              ret ++;
         }
    }
    return ret;
}

int main(){
    int a;
    int b;
    int c;
    list<int> d;
    cin >> a >> b ;
    for (int i = 0; i<b.size(); i++){
         cin >> c;
         d.push_back(c);
    }
   int e = solveMeFirst(d,b);
    cout << e;
    return 0;
}