#include <bits/stdc++.h>
using namespace std;
long long N, X, P, Q;
vector<long long> A;
int main() {
  A.assign(N + 10, 0);
  cin >> N >> X;
  for (long long i = 1; i <= N; i++) cin >> A[i];
  sort(&A[1], &A[N + 1]);
  P = 0;
  Q = 0;
  for (long long i = 1; i <= N; i++) {
    if (Q + A[i] <= X) {
      P++;
      Q += A[i];
    } else
      break;
  }
  if (Q != X && P == N) P--;
  cout << P << endl;
}
