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 for i in range(1,N+1): a = A[i-1] for j in range(K+1): dp[i][j] += dp[i-1][j] if j+a<=K: dp[i][j+a] += dp[i-1][j] if dp[-1][-1]==0: exit(print(-1)) dpr = [set() for _ in range(N+1)] dpr[-1].add(K) ans = 0 for i in range(N,0,-1): a = A[i-1] c1, c2 = 0, 0 for num in dpr[i]: if dp[i-1][num]>0: c1 += 1 dpr[i-1].add(num) if num-a>=0 and dp[i-1][num-a]>0: c2 += 1 dpr[i-1].add(num-a) l = len(dpr[i]) if (c1==l and c2==0) or (c1==0 and c2==l): ans += 1 print(ans)