#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (auto &e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  partial_sum(begin(a), end(a), begin(a));
  int ans = upper_bound(begin(a), end(a), x) - begin(a);
  if (a.back() < x) --ans;
  cout << ans << endl;
  return 0;
}
