#include <bits/stdc++.h>
using namespace std;
int n, x, a[110];
int main() {
  cin >> n >> x;
  int sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(a, a + n);
  int ans;
  sum < x ? ans = -1 : ans = 0;
  sum = 0;
  for (int i = 0; i < (int)(n); i++) {
    if (sum + a[i] <= x) {
      ans++;
      sum += a[i];
    } else
      break;
  }
  cout << ans << endl;
}
