{-# LANGUAGE PartialTypeSignatures #-}
module Main (main) where

import qualified Data.ByteString.Char8 as C8
import qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  [x,n] <- readInts
  readInts >>= output . solve (x,n)

solve :: (Int,Int) -> [Int] -> _
solve (x,0) _ = x
solve (x,1) [y] = if x==y then x+1 else x
solve (x,_) xs = check $ tail $ zip [x,x-1..] [x..]
  where
    check ((y1,y2):ys)
      | y1 `elem` xs && y2 `elem` xs = check ys
      | y1 `elem` xs = y2
      | y2 `elem` xs = y1
      | otherwise = y1

output :: _ -> IO ()
output = print

-- utils
readInts :: IO [Int]
readInts = L.unfoldr (C8.readInt . C8.dropWhile C.isSpace) <$> C8.getLine