object Main
  extends App {
  val _   = readInt
  val ans = readLine
    .split(" ")
    .map(_.toInt)
    .zipWithIndex
    .map { case (n, i) => n == i + 1 }
    .foldLeft((0, false))((acc, h) => (acc._2, h) match {
      case (false, true) => (acc._1 + 1, true)
      case _             => (acc._1, false)
    })
    ._1
  println(ans)
}