#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int64_t n, x;
  cin >> n >> x;
  vector<int64_t> a(n);
  for (int i = 0; i < (int)(n); i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  int64_t cnt = 0;
  for (int i = 0; i < (int)(n); i++) {
    cnt += a.at(i);
    if (cnt > x) {
      cout << i << endl;
      return 0;
    }
  }
  cout << n << endl;
}
