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