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) == (0, 1) = 1
    | left == right = left
    | otherwise = if (or $ drop (k - (a !! mid - 1)) f) then
                                                        solve a k left mid
                                                        else
                                                        solve a k (mid + 1) right
        where mid = (left + right) `div` 2
              f0 = True : replicate (k - 1) False
              f = dp (a `subs` mid) f0
              subs a idx = take (idx - 1) a ++ drop idx 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 a' k 0 $ length a'
