fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val pp = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    var cnt = 0
    var idx = 0

    while (idx <= n-2) {
        if (pp[idx] == idx+1 || pp[idx+1] == (idx+1)+1) {
            val tmp = pp[idx]
            pp[idx] = pp[idx+1]
            pp[idx+1] = tmp
            cnt++
            idx+=2
        } else {
            idx++
        }
    }

    if (pp[n-1] == n) cnt++

    println(cnt)
}

