#include <bits/stdc++.h>
using namespace std;
int n, x, a, ans = 0;
vector<int> as;
int main() {
  cin >> n >> x;
  for (int i = 0; i < n; ++i) {
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  for (int i = 1; i <= n; ++i) {
    int s = accumulate(as.begin(), as.begin() + i, 0);
    if (s <= x) {
      ans = max(ans, i);
      if (i == n && s < x) ans--;
    }
  }
  cout << ans << endl;
  return 0;
}
