module Main where

import Data.List
import Control.Monad
import Debug.Trace
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)

import qualified Data.Map.Strict as M
import Control.Arrow ((>>>))
import Data.Monoid (mconcat)

newtype PQ a =  PQ {getPQ :: M.Map a Int}

enqueuePQ :: Ord a => a -> PQ a -> PQ a
enqueuePQ a = PQ . M.alter (Just . maybe 1 (+1)) a . getPQ

dequeuePQ :: Ord a => PQ a -> (Maybe a, PQ a)
dequeuePQ (PQ pq) = 
    if pq == M.empty then (Nothing, PQ M.empty)
    else
        let
            maxVal = fst $ M.findMax pq
            newPQ = M.alter (>>= (subtract  1 >>> \n -> if n > 0 then Just n else Nothing)) maxVal pq
        in
            (Just maxVal, PQ newPQ)

modifyFirst :: Ord a => (a -> a) -> PQ a -> PQ a
modifyFirst f pq = let
    (maxVal, newPQ) = dequeuePQ pq
    in
        case maxVal of 
            Just n -> enqueuePQ (f n) newPQ
            Nothing -> pq

fromListPQ :: Ord a => [a] -> PQ a
fromListPQ = foldr enqueuePQ emptyPQ

emptyPQ :: Ord a => PQ a
emptyPQ = PQ M.empty


toListPQ :: Ord a => PQ a -> [a]
toListPQ pq = let
    (mayVal, newPQ) = dequeuePQ pq
    in
        case mayVal of
            Nothing -> []
            Just v -> v : toListPQ newPQ

readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as = let
    (fo, la) = span f as
    las = case la of
        [] -> []
        xs -> split f $ tail xs
    in
        case fo of
            [] -> las
            xs -> xs : las

solve :: [Int] -> Int -> Int
solve as waribiki = let
    pq = fromListPQ as
    pq' = foldr (\_ q -> modifyFirst (`div` 2) q) pq [1..waribiki]
    in
        sum $ toListPQ pq'

main = do
    (n, m) <- readTuple2
    as <- readInts
    print $ solve as m
