import Control.Applicative

main :: IO()
main = do
	[n,_] <- map (read::String->Int) . words <$> getLine
	d <- concat . words <$> getLine
	print $ head [i | i<-[n..], and (map (not . flip elem (show i)) d)]