#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  int count = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    sum = sum + vec.at(i);
  }
  if (x >= sum) {
    count = n;
  } else {
    for (int j = 0; j < n - 1; j++) {
      x = x - vec.at(j);
      count++;
      if (x - vec.at(j + 1) <= 0) {
        break;
      }
    }
  }
  cout << count << endl;
}
