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