main :: IO ()
main = do
  [n, _, x] <- readInts
  as <- readInts
  print $ solve n x as

solve :: Int -> Int -> [Int] -> Int
solve n x as = (step 0 x as) `min` (step x n as)

step :: Int -> Int -> [Int] -> Int
step p q as = q - p + l
  where l = length [ a | a <- as, p < a, a < q ]
