#incldue<iostream>
#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;
  }
  cout << pt << endl;
  return 0;
}