n, k = map(int, input().split()) a = list(map(int, input().split())) dp = [[0] * (k + 1) for _ in range(n + 1)] dp[0][0] = 1 mem = [-1] * (k + 1) for i in range(n): for j in range(k + 1): if j - a[i] >= 0: dp[i + 1][j] |= dp[i][j - a[i]] dp[i + 1][j] |= dp[i][j] if mem[j] == -1 and dp[i + 1][j]: mem[j] = i + 1 if not dp[n][k]: exit(print(-1)) now = (n, k) l1 = [] while now != (0, 0): cn, ck = now if dp[cn - 1][ck - a[cn - 1]]: l1.append(cn - 1) now = (cn - 1, ck - a[cn - 1]) else: now = (cn - 1, ck) l2 = [] now = (n, k) while now != (0, 0): cn, ck = now if dp[cn - 1][ck]: now = (cn - 1, ck) else: l2.append(cn - 1) now = (cn - 1, ck - a[cn - 1]) print(len(set(l1) & set(l2)))