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