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