{-# LANGUAGE ViewPatterns #-}

import qualified Data.Vector.Unboxed as VU
import Data.ByteString.Char8 as B
import Data.Char
import Data.Maybe
import Control.Applicative
import Control.Monad

c :: VU.Vector Int -> Char -> Char
c ds i = intToDigit m
    where
        m = VU.minimum $ VU.filter (\i -> VU.notElem i ds && i' <= i) $ VU.fromList [0..9]
        i' = digitToInt i

solve :: B.ByteString -> VU.Vector Int -> B.ByteString
solve (B.uncons -> Nothing) ds = B.empty
solve (B.uncons -> Just (i, B.uncons -> Nothing)) ds = B.singleton (c ds i) 
solve (B.uncons -> Just (i, B.uncons -> Just (x, xs))) ds = B.cons (c ds i) (solve (B.cons x xs) ds)

main = do
    [n, k] <- B.words <$> B.getLine :: IO [B.ByteString]
    let k' = fst . fromJust . B.readInt $ k
    ds <- VU.unfoldrN k' (B.readInt . B.dropWhile isSpace) <$> B.getLine :: IO (VU.Vector Int)
    print . fst . fromJust . B.readInt $ solve n ds
    