#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int x;
  cin >> x;
  vector<int> a;
  for (int i = 0; i < N; i++) {
    int pt;
    cin >> pt;
    a.push_back(pt);
  }
  sort(a.begin(), a.end());
  int sc = 0;
  while (a.size() > 0) {
    if (a.front() <= x) {
      x -= a.front();
      a.erase(a.begin());
      sc++;
    } else {
      break;
    }
  }
  if (x > 0 && sc > 0) sc--;
  cout << sc << endl;
  return 0;
}
