object Main extends App {
    val n: Int = io.StdIn.readLine().toInt
    val arr: Array[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
    val swapStatus: Array[Int] = Seq.range(0, arr.length).map(i => if(arr(i) == i + 1) 0 else 1).toArray

    val ret = new beg072d().solve(arr, swapStatus, 0, 0)
    // for (i <- 0 to ret._1.length - 1) print(ret._1(i) + " ")
    // println
    println(ret._2)
}
class beg072d {
  def solve(arr: Array[Int], swapStatus: Array[Int], pos: Int, cnt: Int): (Array[Int], Int) = {
    if (pos + 1 >= arr.length) {
      return (arr, cnt)
    }
    if (swapStatus(pos) == 0 && swapStatus(pos + 1) == 0
        || swapStatus(pos) == 0 && swapStatus(pos + 1) == 1
        || swapStatus(pos) == 1 && swapStatus(pos + 1) == 0) {
      val tmp = arr(pos)
      arr(pos) = arr(pos + 1)
      arr(pos + 1) = tmp
      // for (i <- 0 to arr.length - 1) print(arr(i) + " ")
      swapStatus(pos) = 1;
      swapStatus(pos + 1) = 1
      solve(arr, swapStatus, pos + 1, cnt + 1)
    } else {
      solve(arr, swapStatus, pos + 1, cnt)
    }
  }
}