#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, cnt = 0, sum = 0;
  cin >> n;
  cin >> m;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i++) {
    sum += a[i];
    cnt++;
    if (sum >= m) {
      break;
    }
  }
  cout << cnt;
  return 0;
}
