#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 count = 0;
  for (int i = 0; i < n - 1; i++) {
    if (x - a[i] >= 0) {
      count++;
      x -= a[i];
    } else {
      break;
    }
  }
  if (x - a[n - 1] > 0) {
    cout << count << endl;
  } else {
    count++;
    cout << count << endl;
  }
  return 0;
}
