#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const long long INF = 1e15;
int main() {
  long long N, x;
  cin >> N >> x;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end());
  long long ans = 0;
  for (int i = 0; i < N; i++)
    if (x >= A[i]) {
      ans++;
      x -= A[i];
    }
  cout << ans << endl;
  return 0;
}
