#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, res;
  cin >> n >> k;
  res = 0;
  vector<int> vec(n, 0);
  for (int i = 0; i < n; ++i) cin >> vec[i];
  sort(vec.begin(), vec.end());
  for (int i = 0; i < n; ++i) {
    if (k - vec[i] >= 0) {
      k -= vec[i];
      res++;
    }
  }
  if (k > 0 && res > 0) {
    res--;
  }
  cout << res << endl;
  return 0;
}
