#include <bits/stdc++.h>
using namespace std;
vector<int> v;
int main() {
  int n, x, tot = 0, c = 0;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    v.push_back(y);
    tot += y;
  }
  sort(v.rbegin(), v.rend());
  for (int i = 0; i < n; i++) {
    if (v[i] <= x) {
      c++;
      x -= v[i];
      if (i == n - 1 && x > 0) c--;
    }
  }
  cout << c << endl;
}
