#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, ans = 0;
  cin >> n >> m;
  int a[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n, greater<int>());
  for (int i = 0; i < n; i++) {
    if (m >= a[i]) {
      m -= a[i];
      ans++;
    } else
      break;
  }
  cout << ((m != 0) ? ans + 1 : ans) << endl;
}
int main() {
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
