import Data.List (sort)
import Debug.Trace (trace)

dp :: [Int] -> [Bool] -> [Bool]
dp a f = foldl (\lst n -> zipWith (||) lst $ replicate n False ++ lst) f a

solve :: [Int] -> Int -> Int -> Int -> Int
solve a k left right
    | left == right = left
    | otherwise = if (or $ drop (k - (a !! mid)) f) then
                                                    solve a k left (mid - 1)
                                                    else
                                                    solve a k mid right
        where mid = (left + right + 1) `div` 2
              f0 = True : replicate (k - 1) False
              f = dp (a `subs` mid) f0
              subs a idx = take idx a ++ drop (idx + 1) a

main = do
    (n:k:[]) <- fmap read . words <$> getLine :: IO [Int]
    a <- fmap read . words <$> getLine :: IO [Int]
    let a' = sort $ filter (< k) a
    print $ solve (0:a') k 0 $ length a'
