#include <bits/stdc++.h>
using namespace std;
template <class T>
inline size_t fast_upper_bound(const vector<T>& vec, T value) {
  size_t m_len = vec.size();
  size_t low = -1;
  size_t high = m_len;
  assert(m_len < std::numeric_limits<size_t>::max() / 2);
  while (high - low > 1) {
    size_t probe = (low + high) / 2;
    T v = vec[probe];
    if (v > value)
      high = probe;
    else
      low = probe;
  }
  if (high == m_len)
    return m_len;
  else
    return high;
}
clock_t time_p = clock();
void timer() {
  time_p = clock() - time_p;
  cerr << "Execution Time: " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n, x, cnt = 0;
  cin >> n >> x;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (long long i = 0; i < n; i++) {
    if (x >= a[i]) {
      cnt++;
      x -= a[i];
    }
  }
  if (x > 0) {
    if (cnt > 0) cnt--;
  }
  cout << cnt;
  timer();
  return 0;
}
