from collections import deque N,K = map(int,input().split()) ldp = [[False] * (K+1) for _ in range(N+2)] ldp[0][0] = True rdp = [[False] * (K+1) for _ in range(N+2)] rdp[N+1][0] = True INF = float('inf') MIN = [INF for _ in range(K+1)] MAX = [0 for _ in range(K+1)] A = [0] + list(map(int,input().split())) for i in range(1,N+1): for k in range(K+1): ldp[i][k] |= ldp[i-1][k] if k >= A[i]: ldp[i][k] |= ldp[i-1][k-A[i]] for i in reversed(range(1,N+1)): for k in range(K+1): rdp[i][k] |= rdp[i+1][k] if k >= A[i]: rdp[i][k] |= rdp[i+1][k-A[i]] if ldp[N][K]: cnt = 0 for i in range(1,N+1): flag = True for x in range(K+1): if ldp[i-1][x] and rdp[i+1][K-x]: flag = False cnt += flag print(cnt) else: print(-1)