#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;
  int size = 1;
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
    size++;
  }
  for (int i = 0; i < N; i++) {
    all += a.at(i);
  }
  int counter = 0;
  if (all == x) {
    counter = size;
  } else if (all > x) {
    counter = size - 1;
  } else {
    sort(a.begin(), a.end());
    for (int i = 0; i < N; i++) {
      x = x - a.at(i);
      if (x >= a.at(i + 1))
        counter++;
      else
        break;
    }
  }
  cout << counter << endl;
  return 0;
}
