import Control.Applicative
import Control.Monad
import Data.List
import Data.Char
strToInt s = (read :: String -> Int) s
strToInteger s = (read :: String -> Integer) s
strToDouble s = (read :: String -> Double) s

main :: IO ()
main = do
    [n, k] <- words <$> getLine
    l <- getLine
    let likes = ['0'..'9'] \\ l
    -- 出力
    putStrLn $ solve likes n

solve :: String -> String -> String
solve likes [] = []
solve likes n = if null gts then c : replicate (length n) (head likes) else head gts : solve likes (tail n)
    where gts = (\x -> filter (>= x) likes) (head n)
          c = if head likes == '0' then likes!!1 else likes!!0
