#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;
  for (int j = 0; j < vec.size(); j++) {
    x = x - vec.at(j);
    if (x > 0) {
      count++;
    }
    if (x <= 0) {
      break;
    }
  }
  if (x > 0) {
    count = count - 1;
  }
  cout << count << endl;
}
