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