#include <bits/stdc++.h>
using namespace std;
template <typename T>
using V = vector<T>;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N, S;
  cin >> N >> S;
  V<int> A(N);
  for (auto &e : A) {
    cin >> e;
  };
  sort(begin(A), end(A));
  int cnt = 0;
  for (int(i) = 0; (i) < (N); ++(i)) {
    if (S >= A[i]) {
      S -= A[i];
      ++cnt;
    } else {
      break;
    }
  }
  if (S && cnt) --cnt;
  cout << cnt << endl;
}
