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