#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int x;
  priority_queue<int, vector<int>> a;
  for (int i = 0; i < n; ++i) {
    cin >> x;
    if (x <= m)
      ;
    a.push(x);
  }
  int sum = 0;
  while (m > 0) {
    m -= a.top();
    a.pop();
    ++sum;
  }
  cout << sum;
}
