n,k = map(int,input().split()) a = list(map(int,input().split())) max_k = k+1 dp = [set() for _ in range(max_k)] dp[0].add(0) for i in range(n): aa = a[i] n_dp = [set() for _ in range(max_k)] for j in range(max_k): if n_dp[j]: pass # p = set() # for x in dp[j]: # if x in n_dp[j]: # p.add(x) # n_dp[j] = p else: for x in dp[j]: n_dp[j].add(x) if dp[j]: if aa + j <= k: if dp[aa + j]: p = set() for x in dp[aa + j]: if x in dp[j]: p.add(x) n_dp[aa + j] = p else: n_dp[aa+j].add(i+1) for x in dp[j]: n_dp[aa+j].add(x) dp = n_dp # print(dp) if dp[-1]: print(len(dp[-1])-1) else: print(-1)