fun MutableList<Int>.swap(index1: Int, index2: Int) {
    val tmp = this[index1] // 'this' corresponds to the list
    this[index1] = this[index2]
    this[index2] = tmp
}

fun main(args: Array<String>) {
    var N = readLine()!!.toInt()
    var A = readLine()!!.split(' ').map { it.toInt() }.toMutableList()

    var res = 0
    for (i in 0 until N-1) {
        if (A[i] == i+1) {
            res++
            A.swap(i, i+1)
        }
    }

    if (A[N-2] == N-1 || A[N-1] == N) res++

    println(res)
}