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