N, K = map(int, input().split()) A = list(map(int, input().split())) pre = [0] * (2 * K + 1) pre[0] = 1 for i in range(N): dp = [0] * (2 * K + 1) for j in range(2 * K + 1): dp[j] |= pre[j] if j - A[i] >= 0: dp[j] |= pre[j - A[i]] dp, pre = pre, dp ans = 0 for i in range(N): if pre[K] and not pre[K + A[i]]: ans += 1 print(ans) if ans else print(-1)