#include <bits/stdc++.h>
using namespace std;
int flash_drives[100001];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &flash_drives[i]);
  }
  sort(flash_drives, flash_drives + n, greater<int>());
  int l = 0;
  int sum = 0;
  for (int i = 0; i < n; i++) {
    if (sum < m) {
      sum += flash_drives[i];
      l++;
    } else
      break;
  }
  printf("%d \n", l);
  return 0;
}
