#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, x;
  int A[N];
  int res = 0;
  cin >> N >> x;
  for (int i = 0; i < N; ++i) cin >> A[i];
  sort(A, A + N);
  for (int i = 0; i < N; ++i) {
    if (x >= A[i]) {
      ++res;
      x = x - A[i];
    }
  }
  cout << res << endl;
}
