#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  cin >> N >> x;
  int distributing;
  vector<int> distrubiton;
  for (int count(0); count < N; ++count) {
    cin >> distributing;
    distrubiton.push_back(distributing);
  }
  sort(distrubiton.begin(), distrubiton.end());
  int tempsum(0);
  for (auto each : distrubiton) tempsum += each;
  int sum(0), counting(0), total = x;
  for (auto each : distrubiton) {
    if (x >= each) {
      total -= each;
      if (total >= 0) ++counting;
    }
  }
  if (total > 0) {
    --counting;
  }
  if (counting > 0)
    cout << counting;
  else
    cout << 0;
  return 0;
}
