n,k = map(int,input().split()) A = list(map(int,input().split())) cand = [[] for i in range(2)] for ind in range(2): dp = [[-2]*(k+1) for i in range(n+1)] dp[0][0] = -1 for i,a in enumerate(A): for j in range(k+1): if dp[i][j] == -2: continue dp[i+1][j] = max(dp[i+1][j],dp[i][j]) if j+a <= k: dp[i+1][j+a] = i if dp[-1][k] == -2: print(-1) exit() now = k for i in range(n+1)[::-1]: cand[ind].append(dp[i][now]) now -= A[dp[i][now]] if now == 0: break A = A[::-1] s1 = set(cand[1]) s2 = set(cand[0]) print(len(s1 & s2))