#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int i, j = 0, a[n];
  for (i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  for (i = n - 1; i >= 0; i--) {
    m = m - a[i];
    j++;
    if (m <= 0) {
      cout << j;
      return 0;
    }
  }
}
