n, k = map(int, input().split()) A = list(map(int, input().split())) dp = [False] * (2 * k + 1) dp[0] = True for a in A: for i in range(2 * k, a - 1, -1): dp[i] |= dp[i - a] if not dp[k]: print(-1) exit() ans = 0 for a in A: if not dp[a + k]: ans += 1 print(ans)