import sys input = sys.stdin.readline #input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] def main(): N,K = map(int,input().split()) A = list(map(int,input().split())) #dpl[i][j]:左からi番目まで見て和がjを作れるか0/1 dpl = [[0]*(N+1) for _ in range(K+1)] dpl[0][0] = 1 #dpr[i][j]:右からi番目まで見て和がjを作れるか0/1 dpr = [[0]*(N+1) for _ in range(K+1)] dpr[0][0] = 1 #配るDP for i in range(N): for j in range(K+1): #使わない dpl[j][i+1] |= dpl[j][i] #使う if j+A[i] <= K: dpl[j+A[i]][i+1] |= dpl[j][i] for j in range(K+1): #使わない dpr[j][i+1] |= dpr[j][i] #使う if j+A[N-1-i] <= K: dpr[j+A[N-1-i]][i+1] |= dpr[j][i] if dpl[K][N] == 0: print(-1);exit() #print(dpl) #print(dpr) ans = 0 for i in range(N): for x in range(K+1): if dpl[x][i] == 1 and dpr[K-x][N-1-i] == 1: break else: ans += 1 print(ans) if __name__ == '__main__': main()