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