#include<algorithm>
        #include<deque>
        using namespace std;
        int main(){
          int n,x; cin >> n >> x;
          deque<int> q(n);
          for(int&a:q)cin >> a;
          sort(q.begin(), q.end());
          int pt = 0;
          while(x - *q.begin() >= 0){
            x -= *q.begin();
            q.pop_front();
            pt++;
            if(q.empty())break;
          }
          if(q.empty() && x > 0)pt--;
          cout << pt << endl;
          return 0;
        }