#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int N, x;
  cin >> N >> x;
  vector<int> child(N);
  for (int i = 0; i < N; i++) {
    cin >> child.at(i);
  }
  sort(child.begin(), child.end());
  int sum, res;
  sum = res = 0;
  for (int i = 0; i < N; i++) {
    sum += child.at(i);
    if (sum <= x) {
      res++;
    } else {
      break;
    }
  }
  cout << res << endl;
  return 0;
}
