#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  int all = 0;
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    all += a.at(i);
  }
  int counter = 0;
  if (all == x)
    counter = a.size();
  else {
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++) {
      if (i == N - 1) {
        if (a.at(i) == x) counter++;
        break;
      }
      if (a.at(i) > x)
        break;
      else
        x -= a.at(i);
      counter++;
    }
  }
  cout << counter << endl;
  return 0;
}
