fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val num = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var ans = 0
    for(i in (0 until n-1)) {
        if (num[i] == i + 1) {
            swap(i, i+1, num)
            ans++
        }
    }
    if(num.last() == num.lastIndex + 1) {
        ans++
        swap(num.lastIndex-1, num.lastIndex, num)
    }
    println(ans)
}

fun swap(idx1:Int, idx2:Int, num:MutableList<Int>) {
    val tmp = num[idx1]
    num[idx1] = num[idx2]
    num[idx2] = tmp
}
