#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, x;
  cin >> n >> x;
  vector<long long int> ar(n);
  for (i = 0; i < n; i++) {
    cin >> ar[i];
  }
  sort(ar.begin(), ar.end());
  for (i = 1; i < n; i++) {
    ar[i] += ar[i - 1];
  }
  auto it = upper_bound(ar.begin(), ar.end(), x);
  if (*it == x)
    cout << (it - ar.begin() + 1) << "\n";
  else
    cout << it - ar.begin() << "\n";
}
