### BUGGY CODE ###

def main():
    import sys
    input = sys.stdin.readline

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

    dp_left = [[False] * K for _ in range(N + 1)]
    dp_right = [[False] * K for _ in range(N + 1)]
    dp_left[0][0] = True
    dp_right[0][0] = True
    for i, a in enumerate(A):
        for j in range(K):
            if dp_left[i][j]:
                dp_left[i + 1][j] = True
                if j + a < K:
                    dp_left[i + 1][j + a] = True
    for i, a in enumerate(reversed(A)):
        for j in range(K):
            if dp_right[i][j]:
                dp_right[i + 1][j] = True
                if j + a < K:
                    dp_right[i + 1][j + a] = True

    ans = 0
    for i, a in enumerate(A):
        if a >= K:
            continue
        L = []
        R = []
        for j in range(K):
            if dp_left[i][j]:
                L.append(j)
            if dp_right[N-i-1][j]:
                R.append(j)
        nl = len(L)
        nr = len(R)
        l = 0
        r = nr-1
        ok = 0
        while True:
            if K-a <=L[l] + R[r] < K:
                ok = 1
                break
            elif L[l] + R[r] >= K:
                r -= 1
                if r < 0:
                    break
            else:
                l += 1
                if l >= nl:
                    break
        if not ok:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    import sys
    from array import array
    input = sys.stdin.readline

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

    dp_left = [array('b', [0] * K) for _ in range(N + 1)]
    dp_right = [array('b', [0] * K) for _ in range(N + 1)]
    dp_left[0][0] = 1
    dp_right[0][0] = 1
    for i, a in enumerate(A):
        for j in range(K):
            if dp_left[i][j]:
                dp_left[i + 1][j] = 1
                if j + a < K:
                    dp_left[i + 1][j + a] = 1
    for i, a in enumerate(reversed(A)):
        for j in range(K):
            if dp_right[i][j]:
                dp_right[i + 1][j] = 1
                if j + a < K:
                    dp_right[i + 1][j + a] = 1

    ok = N
    ng = -1
    mid = (ok+ng)//2
    while ok - ng > 1:
        a = A[mid]
        if a >= K:
            ok = mid
            mid = (ok+ng)//2
            continue
        flg = 0
        l = 0
        r = K-1
        while True:
            if dp_right[N-mid-1][r]:
                break
            r -= 1
        while True:
            if K-a <= l+r < K:
                flg = 1
                break
            elif l+r >= K:
                r -= 1
                if r < 0:
                    break
                while True:
                    if dp_right[N-mid-1][r]:
                        break
                    r -= 1
            else:
                l += 1
                if l >= K:
                    break
                while True:
                    if dp_left[mid][l]:
                        break
                    l += 1
                    if l >= K:
                        break
        if flg:
            ok = mid
        else:
            ng = mid
        mid = (ok+ng)//2
    print(ng+1)


if __name__ == '__main__':
    main()