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