#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, a[10007], i, j, ans = 0;
  vector<int> v;
  cin >> n >> m;
  for (i = 0; i < n; i++) {
    cin >> a[i];
    v.push_back(a[i]);
  }
  int c = 0;
  sort(v.begin(), v.end(), greater<int>());
  for (i = 0; i < n; i++) {
    if ((ans + v[i]) <= m) {
      ans = ans + v[i];
      c++;
    } else {
      break;
    }
  }
  if (ans == m) {
    c = c;
  } else if (ans < m) {
    c = c + 1;
  }
  cout << c << '\n';
  return 0;
}
