import Data.Maybe
import Data.List
import Data.Char

main = do
  [n,_] <- map read . words <$> getLine
  ds <- filter isDigit <$> getLine
  putStrLn (iroha n ds)

iroha :: Int -> [Char] -> String
iroha n ds = fromJust $ find (null . intersect ds) $ map show [n..]