#include <bits/stdc++.h>
using namespace std;
int main(void) {
  int n, x, b = 0;
  cin >> n >> x;
  vector<int> a(n), c(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (a[i] <= x)
      c[i] = a[i];
    else
      c[i] = 0;
    x -= a[i];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == c[i]) b++;
  }
  if (x != 0) b--;
  cout << b << endl;
}
