#include <bits/stdc++.h>
using namespace std;
int solver(int childN, int haveCandy, vector<int> childS) {
  int result = 0;
  bool handedFlag = true;
  sort(childS.begin(), childS.end());
  int childC = 0;
  while (handedFlag) {
    haveCandy = haveCandy - childS.at(childC);
    if (0 <= haveCandy) {
      result = result + 1;
      childC = childC + 1;
      if (childC == childN) {
        if (0 < haveCandy) {
          result = result - 1;
        }
        break;
      } else {
        handedFlag = false;
      }
    }
  }
  return result;
}
int main(void) {
  int N, x;
  int answer = 0;
  cin >> N >> x;
  vector<int> a(N);
  for (int j = 0; j < N; j++) {
    cin >> a.at(j);
  }
  answer = solver(N, x, a);
  cout << answer << endl;
  return 0;
}
