import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [m, _] <- map read . words <$> getLine
  d      <- filter (/= ' ') <$> getLine
  print $ minimum $ filter (null . findIndices (`elem` d) . show) [m .. 20000]
