#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, x;
  cin >> n >> x;
  vector<long long> a(n);
  for (auto &e : a) {
    cin >> e;
  }
  sort(begin(a), end(a));
  for (int i = 0; i < n - 1; i++) {
    a[i + 1] += a[i];
  }
  int r = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == x) {
      r = i + 1;
    } else if (a[i] < x) {
      r = i;
    }
  }
  cout << r << endl;
}
