#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t n, x;
  cin >> n >> x;
  vector<int64_t> v;
  for (auto i = 0; i < n; i++) {
    int64_t a;
    cin >> a;
    v.push_back(a);
  }
  sort(begin(v), end(v));
  int64_t child = 0;
  for (auto i = 0; i < n && x > 0; i++) {
    child++;
    if (v[i] <= x) {
      x -= v[i];
    }
  }
  cout << child << endl;
  return 0;
}
