import Control.Monad.State (State, evalState, gets, modify)
import Data.Map (Map, lookup, insert, empty)
import Data.Maybe (maybe)
import Data.List
main = getLine >>= main' . fmap read . words
    where
        main' [n, k] = getLine >>= print . solve n k . sort . fmap read . words

solve ::  Int -> Int -> [Int] -> Int
solve n k as = count $ splitAt (n `div` 2) xs
    where
        xs = zip [0..] as

        count (ys, z : zs)
            | run (check z) (0, xs) = count $ splitAt (length ys `div` 2) ys
            | otherwise = length ys + 1 + count (splitAt (length zs `div` 2) zs)
        count ([], _) = 0
        count (ys, _) = count $ splitAt (length ys `div` 2) ys

        check (xn, a) f (nk, (yn, ya) : rs)
            | yn == xn = f (nk, rs)
            | nk < k - a = (||) <$> f (nk, rs) <*> f (nk + ya, rs)
            | otherwise = return $ nk < k
        check (_, a) _ (nk, _) = return $ k - a <= nk && nk < k

type Memoizer a b = a -> State (Map a b) b

run :: (Ord a) => (Memoizer a b -> Memoizer a b) -> a -> b
run f = flip evalState empty . memoizeFix f

memoizeFix :: (Ord a) => (Memoizer a b -> Memoizer a b) -> Memoizer a b
memoizeFix f x = gets (Data.Map.lookup x) >>= maybe (g x >>= ((<$) <*> (modify . Data.Map.insert x))) return
    where
        g = f (memoizeFix f)
