#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[]) {
  int N, x;
  cin >> N >> x;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  sort(a.begin(), a.end());
  int sum = 0;
  for (int i = 0; i < N; i++) {
    sum += a[i];
    if (sum <= x)
      continue;
    else {
      cout << i << endl;
      return 0;
    }
  }
  sum -= a[N];
  if (x - sum == a[N])
    cout << N << endl;
  else
    cout << N - 1 << endl;
  return 0;
}
