#include using namespace std; const int MAXK = 1000; using Line = bitset; int main() { int N, K; cin >> N >> K; vector A(N); for (int &x : A) cin >> x; Line ans; ans.set(0); for (int x : A) ans |= ans << x; if (!ans[K]) { cout << -1 << endl; return 0; } vector check(K + 1, -1); int ret = 0; for (int i = 0; i < N; ++i) { if (check[A[i]] != -1) { ret += check[A[i]]; continue; } Line ans; ans.set(0); for (int j = 0; j < N; ++j) if (j != i) { ans |= ans << A[j]; if (ans[K]) break; } check[A[i]] = !ans[K]; if (!ans[K]) ++ret; } cout << ret << endl; }