AtCoDeer the deer has N cards with positive integers written on them. The number on the i-th card (1≤i≤N) is a_i.
Because he loves big numbers, he calls a subset of the cards good when the sum of the numbers written on the cards in the subset, is K or greater.
Then, for each card i, he judges whether it is unnecessary or not, as follows:
 - If, for any good subset of the cards containing card i, the set that can be obtained by eliminating card i from the subset is also good, card i is unnecessary.
 - Otherwise, card i is NOT unnecessary.
Find the number of the unnecessary cards. Here, he judges each card independently, and he does not throw away cards that turn out to be unnecessary.

-----Constraints-----
 - All input values are integers.
 - 1≤N≤5000
 - 1≤K≤5000
 - 1≤a_i≤10^9 (1≤i≤N)

-----Partial Score-----
 - 300 points will be awarded for passing the test set satisfying N,K≤400.

-----Input-----
The input is given from Standard Input in the following format:
N K
a_1 a_2 ... a_N

-----Output-----
Print the number of the unnecessary cards.

-----Sample Input-----
3 6
1 4 3

-----Sample Output-----
1

There are two good sets: {2,3} and {1,2,3}.
Card 1 is only contained in {1,2,3}, and this set without card 1, {2,3}, is also good. Thus, card 1 is unnecessary.
For card 2, a good set {2,3} without card 2, {3}, is not good. Thus, card 2 is NOT unnecessary.
Neither is card 3 for a similar reason, hence the answer is 1.

Difficulty: interview

Starter code:

Solutions:
n, k = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse=True)

temp = 0
ans = 0

for x in a:
    if temp + x < k:
        temp += x
        ans += 1
    else:
        ans = 0

print(ans)

'''
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う

もう1つの方法は分からない
'''

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N,K = list(map(int, input().split()))
    a = list(map(int, input().split()))
    a = sorted(a)
    a = a[:bisect_left(a, K)]
    n = len(a)


    import numpy as np
    def dp(omit):
        dp = np.zeros((n+1, K), dtype=np.bool)
        dp[0,0] = 1
        for i in range(n):
            # まとめて遷移
            dp[i+1] |= dp[i]
            if i != omit and a[i] < K:
                dp[i+1,a[i]:] |= dp[i,:K-a[i]]
        # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
        for j in range(max(0, K-a[omit]), K):
            if dp[n,j]:
                return True
        # なければ不要
        return False


    # def dp(num):
    #     dp = [[0]*(K) for _ in range(n)]
    #     dp[0][0] = 1
    #     b = a[:num]+a[num+1:] #N-1個
    #     for i in range(n-1):
    #         for j in range(K):
    #             if b[i]<=j:
    #                 dp[i+1][j] = dp[i][j-b[i]] or dp[i][j]
    #             else:
    #                 dp[i+1][j]=dp[i][j]
    #     return any(dp[n-1][K-a[num]:])

    left = 0
    right = n-1
    while left<=right:
        mid = (left+right)//2
        if dp(mid):
            right = mid-1
        else:
            left = mid+1
    print((right+1))

def __starting_point():
    main()

__starting_point()

from itertools import accumulate
n,k = list(map(int,input().split()))
a = list(map(int,input().split()))
a.sort()
acc = list(accumulate(a))

def maxsum(ls,k):
  l = len(ls)
  if l==0:
    return 0
  dp = [0 for i in range(l+1)]
  dp[0] = 1
  for i in range(1,l+1):
    dp[i] = (dp[i-1]|(dp[i-1]<<ls[i-1]))&((1<<k)-1)
  for b in range(k-1,-1,-1):
    if dp[l] & 1<<b:
      return b

for i in range(n):
  if a[i]>=k:
    a = a[:i]
    break
n = len(a)
if acc[n-1] < k:
  print(n)
  return
sepa=[]
for i in range(n-1):
  if acc[i]<a[i+1]:
    sepa.append(i)
m=len(sepa)
if m==0:
  print((0))
  return
lf = 0
r = m-1
while lf<r:
  mid = (lf+r)//2
  x=sepa[mid]
  sumx = acc[x]
  if maxsum(a[x+1:],k)+sumx >= k:
    r = mid
  else:
    lf = mid+1
if r==0:
  t=sepa[0]
  if maxsum(a[t+1:],k)+acc[t]>=k:
    print((0))
  else:
    print((sepa[r]+1))
else:
  print((sepa[r]+1))


import numpy as np
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
dp1 = np.zeros((N+1, K), dtype=bool)
dp1[0][0] = 1
for i, a in enumerate(A, 1):
    dp1[i, :] = dp1[i-1, :]
    dp1[i, a:] += dp1[i-1, :-a]
dp2 = np.zeros((N+1, K), dtype=bool)
dp2[N][0] = 1
for i, a in zip(list(range(N-1, -1, -1)), A[::-1]):
    dp2[i, :] = dp2[i+1, :]
    dp2[i, a:] += dp2[i+1, :-a]
ans = 0
for a, d1, d2 in zip(A, dp1[:-1], dp2[1:]):
    if a >= K:
        continue
    d2_ = np.zeros(K+a, dtype=np.int32)
    d2_[a:] = d2
    d2_cum = np.cumsum(d2_)
    d2_diff = d2_cum[a:] - d2_cum[:-a]
    d = d2_diff[::-1] * d1
    if (d == 0).all():
        ans += 1
print(ans)



N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()

def check(omit):
    # 部分和DP
    dp = np.zeros((N+1, K), dtype=np.bool)
    dp[0,0] = 1
    for i in range(N):
        # まとめて遷移
        dp[i+1] = np.logical_or(dp[i+1], dp[i])
        if i != omit and A[i] < K:
            dp[i+1,A[i]:] = np.logical_or(dp[i+1,A[i]:], dp[i,:K-A[i]])
    # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
    for j in range(max(0, K-A[omit]), K):
        if dp[N,j]:
            return True
    # なければ不要
    return False

A.sort()
print((bisearch_min(-1, N, check)))


N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort(reverse=True)
S=0
ans=0
for a in A:
    if S+a<K:
        S+=a
        ans+=1
    else:ans=0
print(ans)

n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

a = sorted(a)[::-1]
ans = n
sm = 0

for i in range(n):
    if sm + a[i] < k:
        sm += a[i]
    else:
        ans = min(ans, n - i - 1)

print(ans)


N, K = list(map(int, input().split(" ")))
A = sorted(list(map(int, input().split(" "))), reverse=True)

result = 0
S = sum(A)
n = len(A)
s = 0
if S<K:
    result = n
elif S == K:
    result = 0
else:
    for i in range(n):
        if s+A[i] >= K:
            result = n - i - 1
        else:
            s += A[i]

print(result)


from collections import Counter
N,K=list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort()
a.reverse()

tmp=[]
tmp_sum=0
b=[]
for i in a:
	if tmp_sum+i>=K:
		b.append(i)	
	else:
		tmp.append(i)
		tmp_sum+=i

if len(b)==0:
	print(N)
else:
	min_num=b[-1]
	c=Counter(a)
	print(N-(a.index(min_num)+c[min_num]))


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter
    import numpy as np
    #mod = 1000000007

    N,K = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)

    def check(num):
        dp = np.zeros((N+1, K), dtype=np.bool)
        dp[0,0] = 1
        for i in range(N):
            # まとめて遷移
            dp[i+1] |= dp[i]
            #i番目のカードはスルー
            if i != num and a[i] < K:
                dp[i+1,a[i]:] |= dp[i,:K-a[i]]
        return any(dp[N, -a[num]:])

    left = -1
    right = N
    while right - left > 1:
        mid = (left+right)//2
        if check(mid):
            right = mid
        else:
            left = mid
    print(right)

    # 間に合わないよ～><
    # def dp(num):
    #     dp = [[0]*(K) for _ in range(n)]
    #     dp[0][0] = 1
    #     b = a[:num]+a[num+1:] #N-1個
    #     for i in range(n-1):
    #         for j in range(K):
    #             if b[i]<=j:
    #                 dp[i+1][j] = dp[i][j-b[i]] or dp[i][j]
    #             else:
    #                 dp[i+1][j]=dp[i][j]
    #     return any(dp[n-1][K-a[num]:])

def __starting_point():
    main()
__starting_point()

# x < yでyが不要とする。y抜きで[K-y,K)を作れる。
# このときにxを使っていないのならば、xも不要。
# xを使っているのならば、xy抜きで[K-x-y,K-x)を作れる。
# yを加えて、x抜きで[K-x,K)を作れる。
# よってy不要ならばx不要。
import numpy as np
import itertools

N,K = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()

# カードは[0,N)-indexed

def test(i):
  # i番目のカードは不要
  dp = np.zeros(K,dtype=np.bool)
  dp[0] = True
  for a in itertools.chain(A[:i],A[i+1:]):
    dp[a:] = np.logical_or(dp[a:],dp[:-a])
  return not dp[-A[i]:].any()

left = -1 # 不要だと判明
right = N # 不要でないと判明
while right - left > 1:
  mid = (left+right)//2
  if test(mid):
    left = mid
  else:
    right = mid

   
answer = left+1
print(answer)

n,k=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
import numpy as np
def bisearch(t):
  dp=np.full(k,False)
  dp[0]=True
  for i in range(n):
    if i==t:continue
    dp[a[i]:] = np.logical_or(dp[a[i]:], dp[:-a[i]]) 
  return any(dp[max(0,k-a[t]):])
l,r=-1,n
while r-l>1:
  x=(l+r)//2
  if bisearch(x):
    r=x
  else:
    l=x
print(r)

N, K = list(map( int, input().split()))
A = list( map( int, input().split()))
RA = sorted(A)
RA = RA[::-1]
s = 0
ans = 0
for i in range(N):
    a = RA[i]
    if s+a < K:
        s += a
        ans += 1
    else:
        ans = 0
print(ans)
#反例
#5 12
#6 4 3 2 1


N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = min(i,count)
print(count)

N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))[::-1]
S = 0
ans = 0

for a in A:
  if S+a<K:
    S+=a
    ans+=1
  else:
    ans=0

print(ans)

N, K = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse = True)

ans = 0
tmp = 0
for i in a:
    if tmp + i < K:
        ans += 1
        tmp += i
    else:
        ans = 0 #リセット

print (ans)

def d_NoNeed(N, K, A):
    a = sorted(A)
    s = t = 0
    # aのうち要素が大きいものから見ていったとき、
    # その要素を入れても総和がK未満のものだけ加えていく
    # 最後に連続して加えた要素の個数が解となる
    # (それら以外の要素の組み合わせでK以上にでき、かつ、
    #  それらの総和がK未満になるため)
    for i in range(N - 1, -1, -1):
        if s + a[i] < K:
            s += a[i]
            t += 1
        else:
            t = 0
    return t

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_NoNeed(N, K, A))

N,K=map(int,input().split())
A=[int(x) for x in input().split()]
A.sort(reverse=True)
su=0
ans=0
for a in A:
  if su+a < K:
    su+=a
    ans+=1
  else:
    ans=0
print(ans)

N,K=list(map(int,input().split()))
x=[int(p) for p in input().split()]
x.sort()
x = x[::-1]
pp=0
ans=0
for a in x:
  if pp+a < K:
    pp+=a
    ans+=1
  else:
    ans=0
print(ans)


n, k = [int(item) for item in input().split()]
a = sorted([int(item) for item in input().split()], reverse=True)

count = 0
asum = 0
for item in a:
    if asum + item < k:
        asum += item
        count += 1
    else:
        count = 0

print(count)

def main():
    import numpy as np
    from bisect import bisect_left as bl
    mod = 10**9+7
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort()
    dp = np.zeros(k, dtype=np.int32)
    dp[0] = 1
    m = bl(a, k)
    for i in range(m):
        aa = a[i]
        dp[aa:] = (dp[aa:]+dp[:k-aa]) % mod

    def b_search(ok, ng):
        while abs(ok-ng) > 1:
            mid = (ok+ng)//2
            if value(mid):
                ok = mid
            else:
                ng = mid
        return ok

    def value(i):
        if i == -1:
            return True
        if i == m:
            return False
        aa = a[i]
        dp2 = np.zeros(k, dtype=np.int32)
        dp2[:aa] = dp[:aa]
        for j in range(aa, k):
            dp2[j] = (dp[j]-dp2[j-aa]) % mod
        for j in range(k-aa, k):
            if dp2[j] != 0:
                return False
        return True
    print(b_search(-1, m)+1)


main()

import random
N, K = list(map(int, input().split()))
*V, = list(map(int, input().split()))
A = [0]*(N+1)
B = [0]*(N+1)
MASK = 2**(K+1)-1
A[0] = 1
for i in range(N):
    if K <= V[i]:
        A[i+1] = A[i]
    else:
        A[i+1] = (A[i] | ((A[i] << V[i]) & MASK))
B[N] = 1 << K
for i in range(N-1, -1, -1):
    if K <= V[i]:
        B[i] = B[i+1]
    else:
        B[i] = (B[i+1] | (B[i+1] >> V[i]))

ans = N
for i in range(N):
    if K <= V[i]:
        ans -= 1
        continue
    a = A[i]; b = B[i+1]
    VM = 2**(V[i]+1)-2
    l = 1
    while a and b and l:
        if a & 1 and b & VM:
            ans -= 1
            break
        l = max((a & -a).bit_length()-1, (b & -b).bit_length()-V[i]-1)
        a >>= l; b >>= l
print(ans)


import sys
from itertools import chain

n, k, *a = map(int, sys.stdin.read().split())
*a, = map(lambda x: min(k, x), a)
# bitsが大きくなりすぎないように前処理
a.sort()

mask = (1 << k) - 1
def is_needed(i):
    res = 1
    for j in chain(a[:i], a[i+1:]):
        res |= res << j
        res &= mask
    return res >> (k - a[i]) 
    # k - a[i]番目以降のbitが1つでも立っていれば、a[i]はneeded

def main():
    lo = 0
    hi = n - 1
    while lo <= hi:
        i = (lo + hi) // 2
        if is_needed(i):
            hi = i - 1
        else:
            lo = i + 1
    
    # hi: neededとなる最小のindex
    return hi + 1
    
def __starting_point():
    ans = main()
    print(ans)
__starting_point()

import numpy as np
import itertools

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

def check(i): #i番目のカードを使わなかった時
    dp = np.zeros(K, dtype = np.bool) #配列の初期化 
    #本来dp[x][y]の配列を用意すべきだけど、一回見たらそれ以降は見ないから上書きしていく
    #xが何であろうか、作れるかどうかだけが大切
    #dp: kが作れるかどうかだけを記録している
    dp[0] = True
    # print (dp)
    for j in itertools.chain(a[:i], a[i+1:]): #i番目を除いたリストを走査
        dp[j:] = np.logical_or(dp[j:], dp[:-j]) #ある数jを使うと、j以降のもの(N-j)個と前から(N-j)個のどちらかがTrueのものは作れる
    return not dp[-a[i]:].any() #dpのK-a[i]からKの範囲どれかにTrueがあるとFalseを返す

#詳しくはノート参照


# aを昇順並べた後の走査で、
# a_iが必要な時、a_(i+1)も必要
# -->二分探索によりlog Nで探索

la = -1
ua = N
while ua - la > 1:
    mid = (ua + la)//2
    if check(mid):
        la = mid
    else:
        ua = mid

print (ua)


import numpy as np

def main():
    def check(m):
        DP = np.full(k+1, False)
        DP[0] = True
        for i in range(n):
            if i == m:
                continue
            DP[a[i]:] = np.logical_or(DP[a[i]:], DP[:k+1-a[i]])
        return any(DP[i] for i in range(k-a[m], k))

    n,k = map(int, input().split())
    a = list(map(int, input().split()))

    a = [i for i in a if i <k]
    a.sort()
    n = len(a)

    left = -1
    right = n

    while right-left > 1:
        mid = (right+left)//2
        if check(mid):
            right = mid
        else:
            left = mid

    print(right)

main()

N,K = map(int,input().split())
a = list(map(int,input().split()))

def f(N,K,a):
    a.sort()
    if a[0] >= K:
        print(0)
        return

    a = [a[i] for i in range(N) if a[i]<K]
    N = len(a)
    ans = N
    dp = [False]*K
    dp[0] = True
    Smax = 0
    for i,a_ in reversed(list(enumerate(a))):
        if Smax + a_ >= K:
            ans = i
        updated = True
        for j in range(min(Smax,K-a_-1),-1,-1):
            if dp[j]:
                dp[j+a_]=True
                if updated:
                    Smax = max(Smax,j+a_)
                    updated = False
    return ans

print(f(N,K,a))

import numpy as np

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    if sum(a) >= k:
        a.sort()
        L, R = -1, n-1
        while L+1 < R:
            P = (L+R+1)//2
            if k <= a[P]:
                R = P
                continue
            dp = np.zeros((k+1), dtype=np.bool)
            dp[0] = True
            for j in range(n):
                if k <= a[j] or j == P:
                    continue
                dp[a[j]:] |= dp[:-a[j]]
            f = False
            for j in range(k-a[P], k):
                f |= dp[j]
            if f:
                R = P
            else:
                L = P
        print(R)
    else:
        print(n)

def __starting_point():
    main()
__starting_point()

N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

def main():
	N, K = map(int,input().split())
	A = list(map(int,input().split()))
	A.sort(reverse=True)
	no_need = 0
	sub = 0
	for ai in A:
		if sub+ai < K:
			sub += ai
			no_need += 1
		else:
			no_need = 0

	print(no_need)


def __starting_point():
    main()
__starting_point()

import sys
input = sys.stdin.readline
import numpy as np

n, k = map(int, input().split())
A = list(map(int, input().split()))
dp = np.zeros(k, dtype=np.int64)
dp[0] = 1
for i in range(n):
  a = A[i]
  dp[a:] += dp.copy()[:-a]

ans = 0
for i in range(n):
  a = A[i]
  for j in range(max(0, k-a), k):
    temp = dp[j::-a*2].sum()
    if j >= a:
      temp -= dp[j-a::-a*2].sum()
    if temp:
      break
  else:
    ans += 1
print(ans)

N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

N, K = map(int, input().split())
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)

N, K, *A = map(int, open(0).read().split())

A.sort(reverse=True)

cur = 0
ans = 0
for a in A:
    if cur + a < K:
        cur += a
        ans += 1
    else:
        ans = 0

print(ans)

#4 9
#1 3 5 6
#の時に1（正解は0）と出力されるがACになる

N, K = list(map(int, input().split()))
a=list(map(int, input().split()))
a.sort()
ans = N
t = 0
for i in range(N-1, -1, -1) :
  if t+a[i] < K:
    t += a[i]
  else:
    ans = min(ans, i)
print(ans)


N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)


N, K = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)

print(ans)

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)


import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    def need(m):
        s=1
        for i in range(n):
            if i==m:continue
            s|=s<<aa[i]
            s&=mask
        #print(m,bin(s),bin(s>>k-aa[m]))
        if s>>k-aa[m]:return True
        return False

    n,k=MI()
    mask=(1<<k)-1
    #print(bin(mask))
    aa=LI()
    aa.sort()
    for i in range(n):
        if aa[i]>k:
            aa=aa[:i]
            break
    n=len(aa)
    #print(aa)
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        #while aa[m-1]==aa[m]:m-=1
        #print(m,aa[m],need(m))
        if need(m):r=m
        else:l=m
    print(l+1)

main()

n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse = True)
ans = n
s, cnt = 0, 0
for i in a:
    cnt += 1
    if s + i < k:
        s += i
    else:
        ans = n - cnt
print(ans)

def d_no_need(N, K, A):
    from bisect import bisect_left
    # 値がK以上の要素は単体で不必要でない要素になれる
    A.sort()
    a_sorted = A[:bisect_left(A, K)]
    ans = len(a_sorted)  # a_sortedの要素は不必要となりうる

    dp = [False] * K  # dp[k]:a_sortedの一部の和を取った値をKにできるか？
    dp[0] = True
    current_max = 0
    for idx, a in reversed(list(enumerate(a_sorted))):
        if current_max + a >= K:
            ans = idx

        first_update = True
        for j in range(min(current_max, K - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True
                if first_update:
                    current_max = max(current_max, j + a)
                    first_update = False
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_no_need(N, K, A))

# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,K = map(int,input().split())
A = list(map(int,input().split()))

A.sort()

ans = N
total = 0

for i in range(N):
    # 後ろ(大きい方) からみていく
    a = A[N-1-i]
    # 合計に加えても K を超えないなら, 最小の部分集合に必要
    if total + a < K:
        total += a
    # そうでない場合, 不要
    else:
        ans = min(ans, N-1-i)

print(ans)

def d_no_need(N, K, A):
    card = sorted(A, reverse=True)
    s = 0  # カードの値の総和
    ans = 0  # 不必要なカードの枚数
    # Aのうち要素が大きいものから見ていったとき、
    # その要素を入れても総和がK未満のものだけ加えていく
    # 最後に連続して加えた要素の個数が解となる
    # (それら以外の要素の組み合わせでK以上にでき、かつ、
    #  それらの総和がK未満になるため)
    for a in card:
        if s + a < K:
            s += a
            ans += 1
        else:
            ans = 0
    return ans

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(d_no_need(N, K, A))

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)
print(ans)

'''
notes:
1-->we include elems that are less than k  
2-->if some x is necessary all elems grtr than x are also necessary 
Base for some x to be necessary:: 
     atleast one of the sums in range [sm-x,sm) must be possible 
     excluding x  
now at any instance after traversing x elements 
we make sure that we have max posible sm <k 
now 
if x+sm <k 
    we cannot include this anyway 
otherwise
    we can make a set with {sm,x} now x is important 
BOOYAH (:
'''


N, K = map(int, input().split())
A = [int(x) for x in input().split()]
A.sort()
cards = 0
tail = N
needs = N
while tail:
  for i in range(tail):
    if A[i] + cards >= K:
      cards += A[i - 1]
      tail = i - 1
      needs = i
      break
  else:
    cards += A[i]
    tail = i
print(needs)

import numpy as np

N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))

dp_left = np.zeros((N + 1, K), dtype=bool)
dp_right = np.zeros((N + 1, K), dtype=bool)
dp_left[0, 0] = 1
dp_right[N, 0] = 1

for i in range(N):
    dp_left[i + 1] = dp_left[i]
    dp_right[N - i - 1] = dp_right[N - i]
    if (a := A[i]) < K:
        dp_left[i + 1, a:] |= dp_left[i, :-a]
    if (a := A[N - i - 1]) < K:
        dp_right[N - i - 1, a:] |= dp_right[N - i, :-a]

ans = 0
for i, a in enumerate(A):
    left_true = np.nonzero(dp_left[i])[0]
    right_true = np.nonzero(dp_right[i + 1])[0]

    ss = np.searchsorted(right_true, K - left_true) - 1
    if all(right_true[ss] + left_true + a < K):
        ans += 1

print(ans)


# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from pprint import pprint
from collections import Counter, defaultdict, deque
import queue
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, K, A):
    A.sort()

    s = 0
    ans = N
    for i in range(N-1, -1, -1):
        if s + A[i] < K:
            s += A[i]
        else:
            ans = min(ans, i)
    return ans


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


def __starting_point():
    main()

__starting_point()

import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

N, K = list(map(int, sys.stdin.readline().split()))
A = list(map(int, sys.stdin.readline().split()))


def bisect_left_callable(fn, x, lo, hi):
    """
    (memo) いっぱい呼ぶなら np.searchsorted のほうがベクトル化されててはやそう
    lo から hi-1 のうち、fn の結果が x 以上となる、最も左の値
    bisect.bisect_left と同じ
    https://docs.python.org/ja/3/library/bisect.html
    :param callable fn:
    :param x:
    :param int lo: 最小値
    :param int hi: 最大値 + 1
    :return: lo <= ret <= hi
    """
    while lo < hi:
        mid = (lo + hi) // 2
        if fn(mid) < x:
            lo = mid + 1
        else:
            hi = mid
    return lo


def is_necessary(ai):
    # A[ai] が必要かどうか
    # A[ai] を使わずに K-A[ai] 以上 K 未満を作れるか

    # dp[j]: j を作れる
    dp = np.zeros(K, dtype=bool)
    dp[0] = 1
    for i, a in enumerate(A):
        if i == ai:
            continue
        dp[a:] = dp[a:] | dp[:-a]
    return any(dp[K - A[ai]:])


A.sort()
unnecessary = bisect_left_callable(is_necessary, 1, lo=0, hi=N)
print(unnecessary)



N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))

a = sorted(a)
ans = N
psum = 0
for i in range(N-1, -1, -1) :
    if psum+a[i] < K :
        psum += a[i]
    else :
        ans = min(ans, i)

print(ans)


import sys
input = sys.stdin.readline

N, K = map(int, input().split())
a = list(map(int, input().split()))

a.sort(reverse = True)

subtotal = 0
need = 0
for i in range(N):
    if subtotal + a[i] < K:
        subtotal += a[i]
    else:
        need = i+1
print(N - need)

import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_int():
    return int(input())


def read_str_list():
    return input().split()


def read_str():
    return input()


def solve(n, k, a):
    [x for x in a if x < k]
    n = len(a)
    a.sort()
    s = 0
    lowest = None
    for i in range(n - 1, -1, -1):
        if k - a[i] <= s:
            # a[i] is not unnecessary
            lowest = i
        else:
            # maybe a[i] is unnecessary
            s += a[i]
    if lowest is None:
        return n
    return lowest

n, k = read_int_list()
a = read_int_list()
res = solve(n, k, a)
print(res)


import sys
from itertools import chain

n, k, *a = map(int, sys.stdin.read().split())
*a, = map(lambda x: min(k, x), a)
# bitsが大きくなりすぎないように前処理
a.sort()

mask = (1 << k) - 1
def is_needed(i):
    res = 1
    for j in chain(a[:i], a[i+1:]):
        res |= res << j
        res &= mask
    return res >> (k - a[i]) 

def main():
    # neededとなるindexの最小を求める
    lo = 0 # 可能最小
    hi = n # 可能最大 + 1
    while lo != hi:
        i = (lo + hi) // 2
        if is_needed(i):
            hi = i
        else:
            lo = i + 1

    return hi
    
def __starting_point():
    ans = main()
    print(ans)
__starting_point()

n, k = map(int, input().split())
a = sorted(map(int, input().split()), reverse=True)
s = 0 #sum a which may not be necessary
need = 0
for i in range(n):
    if s + a[i] < k:
        s += a[i]
    else:
        need = i+1
print(n - need)

import numpy as np
import itertools

N, K = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

def check(i): #i番目のカードを使わなかった時
    dp = np.zeros(K, dtype = np.bool)
    #dp[k]はkが作れる時True
    #保持する情報はTrue/Falseのみで良いので1次元DPを上書きしていく(1回でまとめて)
    dp[0] = True
    for j in itertools.chain(a[:i], a[i+1:]): #i番目の無いカードセット
        dp[j:] = np.logical_or(dp[j:], dp[:-j]) #ある数jを使うと、j以降のもの(N-j)個と前から(N-j)個のどちらかがTrueのものは作れる
    return any(dp[K-a[i]:]) #K-a[i]~K-1のうちどれか作れるならa[i]は必要=True

left = -1
right = N
while right - left > 1:
    mid = (right + left)//2
    if check(mid):
        right = mid
    else:
        left = mid

print(right)


# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()

def check(omit):
    # 部分和DP
    dp = np.zeros(K, dtype=np.bool)
    prev = np.zeros(K, dtype=np.bool)
    dp[0] = prev[0] = 1
    for i in range(N):
        # まとめて遷移
        if i != omit and A[i] < K:
            prev[A[i]:] |= dp[:K-A[i]]
        dp = prev.copy()
    # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
    for j in range(max(0, K-A[omit]), K):
        if dp[j]:
            return True
    # なければ不要
    return False

A.sort()
print((bisearch_min(-1, N, check)))


n,k = map(int,input().split())
*l, = list(map(int,input().split()))
l.sort(reverse=True)
m = 0
ans = 0
for i in l:
  if m+i < k:
    m += i
    ans += 1
  else:
    ans = 0
print(ans)

import sys

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        if func(lst[0]):
            return lst[0]
        else:
            return -1
    if func(lst[nh]):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def mkns(a,s,m):
    if a==0:
        return s
    else:
        return (((s+1)<<a)|s) & m

def main():
    N,K=list(map(int,sys.stdin.readline().strip().split()))
    a=list(map(int,sys.stdin.readline().strip().split()))
    a.sort()
    ss=[0]*(N+1)
    pm=(1<<K)-1
    mask=lambda c:(1<<K)-(1<<c)
    nn=0
    def isunnec(i):
        if a[i]>=K:
            return False
        for j in range(i+1,N):
            if a[j]>=K:
                break
            ss[i]=(((ss[i]+1)<<a[j])|ss[i]) & pm
        if ss[i]&mask(K-a[i])==0:
            return True
        return False
    
    for i in range(N):
        if a[i]>=K:
            break
        ss[i+1]=(((ss[i]+1)<<a[i])|ss[i]) & pm
    nn=biser(list(range(N)),isunnec)+1
    print(nn)

def __starting_point():
    main()

__starting_point()

N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

N, K = map( int, input().split())
A = list( map( int, input().split()))
RA = sorted(A)
RA = RA[::-1]
s = 0
ans = 0
for i in range(N):
    a = RA[i]
    if s+a < K:
        s += a
        ans += 1
    else:
        ans = 0
print(ans)

def d_no_need(N, K, A):
    card = sorted(A, reverse=True)
    s = 0
    ans = 0
    for a in card:
        if s + a < K:
            s += a
            ans += 1
        else:
            ans = 0
    return ans

N,K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print((d_no_need(N, K, A)))


N, K = map(int, input().split())
a = list(map(int, input().split()))
 
a = sorted(a)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+a[i] < K :
        t += a[i]
    else :
        ans = min(ans, i)
 
print(ans)

import sys
N,K=map(int, input().split())
a=list(map(int, input().split()))
sum=0
for i in range(0,N):
  sum+=a[i]
if sum<K:#全部不必要
  print(N)
  return
if sum==K:#全部必要
  print(0)
  return
a.sort()
a.reverse()
 
#K未満の最大の数字のラベルはどこ？
l=N
for i in range(N-1,-1,-1):
  if a[i]<K:
    l=i
  else:
    break
 
if l==N:
  print(0)
  return
 
count=N
#lまでの要素が必要か不要かチェック(使いまわし可能)
sum=0
l_list=[]
for j in range(l,N):
  if sum+a[j]<K:
    sum+=a[j]
    l_list.append(a[j])
for i in range(0,l):  
  if sum+a[i]>=K:#必要ってことだ
    count-=1
#lからの要素は自分のことを抜かないといけないことに注意
for i in range(l,N):
  if a[i] in l_list:
    sum=0
    b=a[:]
    C=b.pop(i)
    for j in range(l-1,N-1):
      if sum+b[j]<K:
        sum+=b[j]
    if sum+C>=K:#必要ってことだ
      count-=1
  else:
    count-=1
print(count)

N,K = map(int,input().split())
a = sorted(map(int,input().split()))

count = N
s = 0
for i in range(N-1,-1,-1):
    if s + a[i] < K:
        s += a[i]
    else:
        count = i
print(count)

def d_no_need(N, K, A):
    from bisect import bisect_left
    # 値がK以上の要素は単体で不必要でない要素になれる
    A.sort()
    a_sorted = A[:bisect_left(A, K)]
    ans = len(a_sorted)  # a_sortedの要素は不必要となりうる

    dp = [False] * K  # dp[k]:a_sortedの一部の和を取った値をKにできるか？
    dp[0] = True
    current_max = 0
    for idx, a in reversed(list(enumerate(a_sorted))):
        if current_max + a >= K:
            ans = idx  # これを満たさないaは不必要

        # current_maxはループの中で1回だけ更新する。
        # jを変化させるたびに代入すると時間がかかるため
        updated = True
        for j in range(min(current_max, K - a - 1), -1, -1):
            if dp[j]:
                dp[j + a] = True  # 和をjにできているなら、j+aにもできる
                if updated:
                    current_max = max(current_max, j + a)
                    updated = False
    return ans

N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print((d_no_need(N, K, A)))
# https://beta.atcoder.jp/contests/arc070/submissions/2980516 参考
# https://medaka.5ch.net/test/read.cgi/prog/1534548265/ の>>75によると
# 8 100
# 1 1 8 8 8 25 26 50
# に対して2や5を返すsubmissionが見られるとのこと(実際は0)


n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
a.sort()
import numpy as np
def bisearch(t):
  dp=np.full(k+1,False)
  dp[0]=True
  for i in range(n):
    if i==t:continue
    dp[a[i]:] = np.logical_or(dp[a[i]:], dp[:-a[i]]) 
  return any(dp[max(0,k-a[t]):k])
l,r=-1,n
while r-l>1:
  x=(l+r)//2
  if bisearch(x):
    r=x
  else:
    l=x
print(r)


n,k=list(map(int,input().split()))
a=list(map(int,input().split()))
def card(N,K,A):
    card = sorted(A,reverse=True)
    s=0
    ans=0
    for i in card:
        if s+i<K:
            s+=i
            ans+=1
        else:
            ans=0
    return ans
print((card(n,k,a)))



                
        


# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()

def check(omit):
    # 部分和DP
    dp = np.zeros(K, dtype=np.bool)
    prev = np.zeros(K, dtype=np.bool)
    dp[0] = prev[0] = 1
    for i in range(N):
        # まとめて遷移
        if i != omit and A[i] < K:
            prev[A[i]:] |= dp[:K-A[i]]
        dp = prev.copy()
    # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
    for j in range(max(0, K-A[omit]), K):
        if dp[j]:
            return True
    # なければ不要
    return False

A.sort()
print((bisearch_min(-1, N, check)))


n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
l.sort(reverse=True)
# print(l)
a = 0
maisu = 0
end_maisu = 0
ans = 0
for i in range(n):
    maisu += 1
    a += l[i]
    if a >= k:
        a -= l[i]
        ans += 1
        end_maisu = maisu
        maisu -= 1
end_maisu -= 1
if end_maisu < 0:
    end_maisu = 0
# print(end_maisu - 1)
print((n - ans - end_maisu))


import sys
from itertools import chain

n, k, *a = map(int, sys.stdin.read().split())
*a, = map(lambda x: min(k, x), a)
a.sort()

mask = (1 << k) - 1
def is_needed(i):
    if a[i] == k:
        return True
    res = 1
    for j in chain(a[:i], a[i+1:]):
        res |= (res << j)
        res &= mask
    return res >> (k - a[i]) 

def main():
    lo = -1
    hi = n
    while lo + 1 < hi:
        i = (lo + hi) // 2
        if is_needed(i):
            hi = i
        else:
            lo = i
    
    return hi
    
def __starting_point():
    ans = main()
    print(ans)
__starting_point()

n,k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
a,num,ans = sorted(a),0,n
for i in range(n-1,-1,-1):
	if num+a[i]<k: num+=a[i]
	else: ans = i
print(ans)

n,k,*a=map(int,open(0).read().split())
s=r=0
for x in sorted(a)[::-1]:
	if s+x<k:
		s+=x
		r+=1
	else:
		r=0
print(r)

"""
Σ_[i=m,n]>kのときa(m)以降は凡て必要
(∵ a(i)が必要->a(i+1)が必要)
k-=Σ_[i=m+1,n]として操作を続ける
Σ_[i=1,r]<kとなったときa(r)までが不必要
"""

import sys

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        if func(lst[0]):
            return lst[0]
        else:
            return -1
    if func(lst[nh]):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def mkns(a,s,m):
    if a==0:
        return s
    else:
        return (((s+1)<<a)|s) & m

def main():
    N,K=list(map(int,sys.stdin.readline().strip().split()))
    a=list(map(int,sys.stdin.readline().strip().split()))
    a.sort()
    ss=[0]*(N+1)
    pm=(1<<K)-1
    mask=lambda c:(1<<K)-(1<<c)
    nn=0
    def isunnec(i):
        if a[i]>=K:
            return False
        for j in range(i+1,N):
            if a[j]>=K:
                break
            ss[i]=(((ss[i]+1)<<a[j])|ss[i]) & pm
        # print(bin(ss[i]), bin(mask(K-c)),ss[i]&mask(K-c))
        if ss[i]&mask(K-a[i])==0:
            return True
        return False
    
    for i in range(N):
        if a[i]>=K:
            break
        ss[i+1]=(((ss[i]+1)<<a[i])|ss[i]) & pm
        #if isunnec(i):
        #     nn+=1
        #for j in range(i+1,N):
        #    if a[j]>=K:
        #        break
        #    ss[i]=mkns(a[j],ss[i],pm)
        ##print(bin(ss[i]), bin(mask(K-c)),ss[i]&mask(K-c))
        #if ss[i]&mask(K-a[i])==0:
        #    nn+=1
    #m=len(list(filter(lambda x:x<K, a)))
    nn=biser(list(range(N)),isunnec)+1
    #print(list(map(bin,ss)))
    print(nn)

def __starting_point():
    main()

__starting_point()

# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return list(map(int, input().split()))
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()

def check(omit):
    # 部分和DP
    dp = np.zeros((N+1, K), dtype=np.bool)
    dp[0,0] = 1
    for i in range(N):
        # まとめて遷移
        dp[i+1] |= dp[i]
        if i != omit and A[i] < K:
            dp[i+1,A[i]:] |= dp[i,:K-A[i]]
    # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
    for j in range(max(0, K-A[omit]), K):
        if dp[N,j]:
            return True
    # なければ不要
    return False

A.sort()
print((bisearch_min(-1, N, check)))


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

a = sorted(a)
sum_a = 0
ans = 0
for i in range(n-1, -1, -1):
    if sum_a+a[i] < k:
        sum_a += a[i]
        ans += 1
    else:
        ans = 0
    # print(ans)
print(ans)

import numpy as np


def check(x):
    dp = np.zeros(k, np.bool)
    dp[0] = True
    for e in a[:x] + a[x+1:]:
        dp[e:] |= dp[:-e]

    return dp[-a[x]:].any()


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))

a.sort()

lb = -1
ub = n
while ub - lb > 1:
    m = (lb + ub) // 2
    if check(m):
        ub = m
    else:
        lb = m

print(ub)


n,k,*a=map(int,open(0).read().split())
s=r=0
for x in sorted(a)[::-1]:
	if s+x<k:s+=x;r+=1
	else:r=0
print(r)

N, K = map(int, input().split())
alpha = list(map(int, input().split()))

alpha = sorted(alpha)
ans = N
t = 0

for i in range(N-1, -1, -1) :
    if t+alpha[i] < K :
        t += alpha[i]
    else :
        ans = min(ans, i)

print(ans)

import bisect
from collections import deque
N, K = map(int, input().split())
a = sorted(map(int, input().split()))

# K以上のカードは単体で条件を満たすから考えない
a_k = bisect.bisect_left(a, K, lo=0, hi=N)
A = a[:a_k][::-1]
tmp = 0
N = result = N-(N-a_k)

for n, i in enumerate(A):
    if tmp+i >= K:
        result = N-(n+1)
    else:
        tmp += i

print(result)