#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  long long x;
  cin >> n >> x;
  vector<long long> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  for (int i = 0; i + 1 < n; ++i) {
    a[i + 1] += a[i];
  }
  int ng = n + 1;
  int ok = -1;
  while (abs(ng - ok) > 1) {
    int mid = (ng + ok) / 2;
    if (a[mid] <= x)
      ok = mid;
    else
      ng = mid;
  }
  if (ok == -1)
    cout << 0 << endl;
  else if (a[ok] == x)
    cout << ok + 1 << endl;
  else
    cout << ok << endl;
  return 0;
}
