#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n >> x;
  vector<long long> children(n);
  for (int i = 0; i < n; i++) {
    cin >> children[i];
  }
  sort(children.begin(), children.end());
  long long acc = 0;
  for (auto c : children) {
    if (x < c) {
      break;
    } else {
      x -= c;
      acc++;
    }
  }
  if (acc == 0) {
    cout << 0 << endl;
    return 0;
  }
  if (x == 0) {
    cout << acc << endl;
  } else {
    cout << acc - 1 << endl;
  }
  return 0;
}
