private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val p = readInts()
    val arrangedElements = p.mapIndexed { index, pi -> pi == index + 1 }
    val arrangedGroupSizes = mutableListOf<Int>()

    var previousArranged = false
    var continuousArrangedCounts = 0
    for (arranged in arrangedElements + listOf(false)) {
        if (arranged) {
            continuousArrangedCounts += 1
            previousArranged = true
        } else {
            if (previousArranged) {
                arrangedGroupSizes.add(continuousArrangedCounts)
                continuousArrangedCounts = 0
            }
            previousArranged = false
        }
    }

    println(arrangedGroupSizes.map { (it + 1) / 2 }.sum())
}