import Control.Applicative
import Data.List
main = do
  [n, k] <- map (read :: String -> Int) . words <$> getLine
  ds <- concat . words <$> getLine
  print $ minimum $ filter (\x -> all (\d -> d `notElem` ds) (show x)) $ [n..100 * n]