#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000001;
int a[maxn];
const int mod = 1e9 + 7;
const int inf = 1e9;
char L[200], R[200];
map<int, set<int> > mx, my;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
string getnum(string code) {
  int res = 0;
  int d = 1;
  for (int i = (int)code.length() - 1; i >= 0; i--) {
    res += d * (code[i] - 'A' + 1);
    d *= 26;
  }
  return to_string(res);
}
string ones[] = {"zero",    "one",     "two",       "three",    "four",
                 "five",    "six",     "seven",     "eight",    "nine",
                 "ten",     "eleven",  "twelve",    "thirteen", "fourteen",
                 "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
string tens[]{"twenty", "thirty",  "forty",  "fifty",
              "sixty",  "seventy", "eighty", "ninety"};
long long d[2][111][111];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a, a + n, greater<int>());
  int sum = 0;
  int c = 0;
  for (int i = 0; i < n; i++) {
    if (sum >= m) {
      break;
    }
    sum += a[i];
    c++;
  }
  if (sum >= m)
    cout << c << endl;
  else
    cout << -1 << endl;
}
