#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  long x;
  cin >> N;
  cin >> x;
  vector<long> as;
  for (int i = 0; i < N; i++) {
    long a;
    cin >> a;
    as.push_back(a);
  }
  sort(as.begin(), as.end());
  int k = 0;
  long sum = 0;
  while (sum <= x) {
    sum += as[k];
    k += 1;
  }
  if ((k == N) and (x - sum) > 0) {
    k -= 1;
  }
  cout << k << "\n";
  return 0;
}
