#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  o << "{";
  for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
  o << "}";
  return o;
}
int main() {
  int n, x, a;
  cin >> n >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> a;
    vec[i] = a;
  }
  sort((vec).begin(), (vec).end());
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (x >= vec[i]) {
      x -= vec[i];
      ans++;
    } else
      x -= vec[i];
  }
  if (x > 0) ans--;
  cout << ans << "\n";
}
