#include <bits/stdc++.h>
using namespace std;

int main(int argc, char const *argv[]){
	int n,x;
	int temp,cnt = 0;
	cin >> n >> x;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)	cin >> a.at(i);
	sort(a.begin(), a.end());
	for (int i = 0; i < n; ++i)
	{
		temp = (a[i] <= x) ? a[i] : x;
		b[i] += temp;
		x -= temp;
	}
	if(x > 0) cnt = -1;
	for (int i = 0; i < n; ++i)
	{
		if(a[i] == b[i])	++cnt;
	}
	cout << cnt << endl;
	return 0;
}
