#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for (auto &ai : a) cin >> ai;
  sort(begin(a), end(a));
  vector<int> acc(n + 1);
  for (int i = 0; i < n; i++) acc[i + 1] = acc[i] + a[i];
  if (acc.back() < x) return !(cout << n - 1 << endl);
  cout << prev(upper_bound(begin(acc), end(acc), x)) - begin(acc) << endl;
  return 0;
}
