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