n, k = map(int, input().split()) A = list(map(int, input().split())) dp = [[False] * (k + 1) for _ in range(n + 1)] dp[0][0] = True for i, a in enumerate(A, 1): dp[i] = dp[i - 1].copy() for j in range(k, a - 1, -1): dp[i][j] |= dp[i - 1][j - a] if not dp[n][k]: print(-1) exit() dp2 = [[False] * (k + 1) for _ in range(n + 1)] dp2[n][0] = True for i in range(n - 1, -1, -1): a = A[i] dp2[i] = dp2[i + 1].copy() for j in range(k, a - 1, -1): dp2[i][j] |= dp2[i + 1][j - a] ans = 0 for i, a in enumerate(A): plus = 1 for j in range(k + 1): if dp[i][j] and dp2[i + 1][k - j]: plus = 0 break ans += plus print(ans)