#include <bits/stdc++.h>
using namespace std;
template <class C>
inline bool in_(const typename C::key_type& k, const C& A) {
  return A.find(k) != A.end();
}
inline bool in_(const string& s, const string& S) {
  return S.find(s) != string::npos;
}
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const int inf = 1e9 + 9;
const int maxn = 505;
int A[maxn];
int main() {
  ios::sync_with_stdio(false);
  int n, x;
  while (cin >> n >> x) {
    for (int i = (0); i < (n); ++i) cin >> A[i];
    sort(A, A + n);
    int ans = 0;
    for (int i = (0); i < (n); ++i) {
      if (x >= A[i]) {
        if (i == n - 1 && A[i] != x)
          ;
        else
          ans++;
      }
      x -= A[i];
    }
    cout << ans << endl;
  }
  return 0;
}
