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