main :: IO ()
main = do
    (n, k) <- getPair :: IO (Pair Int)
    ds     <- filter (/= ' ') <$> getLine
    print $ solve n ds

type Pair a = (a, a)
getPair = (\(x:y:_) -> (x, y)) . map read . words <$> getLine :: Read a => IO (Pair a)

solve :: Int -> [Char] -> Int
solve n ds
  | all (`notElem` ds) $ show n = n
  | otherwise                   = solve (succ n) ds
