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