module Main where


main :: IO()
main = do
  getLine
  inputs <- map read . words <$> getLine
  print $ solve inputs

solve :: [Integer] -> Integer
solve = swapWithCount

swapWithCount :: [Integer] -> Integer
swapWithCount inputs = sub (0, inputs) 1 where
  sub :: (Integer, [Integer]) -> Integer -> Integer
  sub (count, [_]) index = count
  sub (count, (x:y:xs)) index
    | x == index  = sub (count + 1, x:xs) (index + 1)
    | otherwise   = sub (count, y:xs) (index + 1)
