#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 3e5 + 10;
const int INF = 1e9;
int n, m, a[MAX_N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) cin >> a[i];
  sort(a + 1, a + n + 1);
  int sum = 0;
  for (int i = n; i >= 1; i--) {
    sum += a[i];
    if (sum >= m) {
      cout << n - i + 1 << endl;
      return 0;
    }
  }
}
