object Main extends App {
    val n: Int = io.StdIn.readLine().toInt
    val arr: Array[Int] = io.StdIn.readLine().split(' ').map(_.toInt)

    val ret = new beg072d().solve(arr, 0, 0)
    println(ret._2)
}
class beg072d {
  def solve(arr: Array[Int], pos: Int, acc: Int): (Array[Int], Int) = {
    if (pos + 1 >= arr.length) {
      return (arr, acc)
    }
    if (arr(pos) == pos + 1) {
      val tmp = arr(pos)
      arr(pos) = arr(pos + 1)
      arr(pos + 1) = tmp
      solve(arr, pos + 1, acc + 1)
    } else  {
      solve(arr, pos + 1, acc)
    }
  }
}