#include <bits/stdc++.h>
using namespace std;
int 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 ans = 0;
  for (int i = 0; i < N; ++i) {
    if (x >= A[i]) {
      x -= A[i];
      ++ans;
    } else
      break;
  }
  if (x > 0) --ans;
  ans = max(ans, 0);
  cout << ans << endl;
  return 0;
}
