#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> a;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int sum = 0, cont = 0;
  for (int i = a.size() - 1; i >= 0; i--) {
    sum += a[i];
    cont++;
    if (sum >= m) break;
  }
  cout << cont;
}
