import sys

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

A=sorted([int(i) for i in input().split()])

sa=sum(A)

def f(x):

    y=A[x]

    if y>=K:

        return True

    L=set()

    L.add(0)

    dp=[False]*(K-y)

    dp[0]=True

    t=0

    for i in range(N):

        if i==x:

            continue

        s=A[i]

        for k in range(t,-1,-1):

            if not dp[k]:

                continue

            if k+s>=K:

                continue

            if k+s+y>=K:

                return True

            dp[k+s]=True

        t=min(t+s,K-y-1)

    return False

ma=N-1

mi=0

if not f(N-1):

    print(N)

    sys.exit()

if f(0):

    print((0))

    sys.exit()

while ma-mi>1:

    #print(ma,mi)

    a=(ma+mi)//2

    if f(a):

        ma=a

    else:

        mi=a

print(ma)





import sys

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

A=sorted([int(i) for i in input().split()])

sa=sum(A)

def f(x):

    y=A[x]

    if y>=K:

        return True

    dp=[False]*(K)

    dp[0]=True

    t=0

    for i in range(N):

        if i==x:

            continue

        s=A[i]

        for k in range(t,-1,-1):

            if k+s>=K:

                continue

            dp[k+s]=dp[k+s]|dp[k]

        t=min(t+s,K-1)

    if sum(dp[K-y:K]):

        return True

    else:

        return False

ma=N-1

mi=0

if not f(N-1):

    print(N)

    sys.exit()

if f(0):

    print((0))

    sys.exit()

while ma-mi>1:

    #print(ma,mi)

    a=(ma+mi)//2

    if f(a):

        ma=a

    else:

        mi=a

print(ma)







import sys

N, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()])
sa = sum(A)


def f(x):
    y = A[x]
    if y >= K:
        return True
    L = set()
    L.add(0)
    dp = [False] * (K - y)
    dp[0] = True
    t = 0
    for i in range(N):
        if i == x:
            continue
        s = A[i]
        for k in range(t, -1, -1):
            if not dp[k]:
                continue
            if k + s >= K:
                continue
            if k + s + y >= K:
                return True
            dp[k + s] = True
        t = min(t + s, K - y - 1)
    return False


ma = N - 1
mi = 0
if not f(N - 1):
    print(N)
    sys.exit()
if f(0):
    print((0))
    sys.exit()
while ma - mi > 1:
    # print(ma,mi)
    a = (ma + mi) // 2
    if f(a):
        ma = a
    else:
        mi = a
print(ma)

import sys

N, K = list(map(int, input().split()))
A = sorted([int(i) for i in input().split()])
sa = sum(A)


def f(x):
    y = A[x]
    if y >= K:
        return True
    dp = [False] * (K)
    dp[0] = True
    t = 0
    for i in range(N):
        if i == x:
            continue
        s = A[i]
        for k in range(t, -1, -1):
            if k + s >= K:
                continue
            dp[k + s] = dp[k + s] | dp[k]
        t = min(t + s, K - 1)
    if sum(dp[K - y : K]):
        return True
    else:
        return False


ma = N - 1
mi = 0
if not f(N - 1):
    print(N)
    sys.exit()
if f(0):
    print((0))
    sys.exit()
while ma - mi > 1:
    # print(ma,mi)
    a = (ma + mi) // 2
    if f(a):
        ma = a
    else:
        mi = a
print(ma)

-    L = set() -    L.add(0) -    dp = [False] * (K - y) +    dp = [False] * (K) -            if not dp[k]: -                continue -            if k + s + y >= K: -                return True -            dp[k + s] = True -        t = min(t + s, K - y - 1) -    return False +            dp[k + s] = dp[k + s] | dp[k] +        t = min(t + s, K - 1) +    if sum(dp[K - y : K]): +        return True +    else: +        return False