import qualified Data.ByteString.Char8 as BS
import           Data.Maybe
import           Data.Vector           ((!))
import qualified Data.Vector           as V

main :: IO ()
main = do
  n <- readLn
  a <- V.fromList . map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine
  let
    solve i = if i == n
      then 0
      else (if (a!(a!i-1)) == i+1 then 1 else 0) + solve (i+1)
  print $ solve 0 `div` 2
