#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
signed main() {
  int N, X;
  cin >> N >> X;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    if (X >= A[i]) {
      X -= A[i];
      res++;
    } else {
      break;
    }
  }
  if (res != 0 && X != 0) res -= 1;
  cout << res << endl;
  return 0;
}
