N, K = map(int, input().split()) A = list(map(int, input().split())) dpl = [[False] * (K + 1) for _ in range(N + 1)] dpr = [[False] * (K + 1) for _ in range(N + 1)] dpl[0][0] = dpr[N][0] = True for i in range(N): for j in range(K + 1): dpl[i + 1][j] = dpl[i][j] for j in range(0, K - A[i] + 1): if dpl[i][j]: dpl[i + 1][j + A[i]] = True for i in range(N - 1, -1, -1): for j in range(K + 1): dpr[i][j] = dpr[i + 1][j] for j in range(0, K - A[i] + 1): if dpr[i + 1][j]: dpr[i][j + A[i]] = True if not dpl[N][K]: print(-1) else: ans = 0 for i in range(N): not_use = True for j in range(K + 1): if dpl[i][j] and dpr[i + 1][K - j]: not_use = False if not_use: ans += 1 print(ans)