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]*(K+1) for _ in range(N+1)] dpl[0][0] = 1 #dpr[i][j]:右からi番目まで見て和がjを作れるか0/1 dpr = [[0]*(K+1) for _ in range(N+1)] dpr[0][0] = 1 #配るDP for i in range(N): a = A[i] for j in range(K+1): #使わない dpl[i+1][j] |= dpl[i][j] #使う if j+a <= K: dpl[i+1][j+a] |= dpl[i][j] a = A[N-1-i] for j in range(K+1): #使わない dpr[i+1][j] |= dpr[i][j] #使う if j+a <= K: dpr[i+1][j+a] |= dpr[i][j] if dpl[N][K] == 0: print(-1);exit() #print(dpl) #print(dpr) ans = 0 for i in range(N): for x in range(K+1): if dpl[i][x] == 1 and dpr[N-1-i][K-x] == 1: break else: ans += 1 print(ans) if __name__ == '__main__': main()