#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);
  long long N, x;
  cin >> N >> x;
  vector<long long> A(N);
  for (long long i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.begin(), A.end());
  long long cnt = 0;
  for (long long i = 0; i < N; i++) {
    if (A[i] <= x) {
      x -= A[i];
      cnt++;
    }
  }
  if (x) cnt--;
  cout << max(0LL, cnt) << endl;
  return 0;
}
