import collections N,K = map(int,input().split()) A = list(map(int, input().split())) A.sort(reverse=True) CA = collections.Counter(A) if sum(A)==K: print(N) exit() if CA[1]>K: print(0) exit() DP = [-1]*(K+1) for i in range(N): for j in reversed(range(K)): if DP[j]!=-1 and j+A[i]<=K and DP[j+A[i]]==-1: DP[j+A[i]]=i else: pass if DP[K]!=-1: break if DP[A[i]]==-1: DP[A[i]]=i if DP[K]==-1: print(-1) exit() v = K L = [] B = [] while v>0: L.append(DP[v]) B.append(A[DP[v]]) v-=A[DP[v]] ans = 0 CB = collections.Counter(B) for k,v in CB.items(): if CB[k]==CA[k]: DP = [-1]*(K+1) for i in range(N): if A[i]==k: continue for j in reversed(range(K)): if DP[j]!=-1 and j+A[i]<=K and DP[j+A[i]]==-1: DP[j+A[i]]=i else: pass if DP[K]!=-1: break if DP[A[i]]==-1: DP[A[i]]=i if DP[K]==-1: ans+=v print(ans)