fun main(arg: Array<String>) {
    val N = nextInt()
    val P = listOfInt(-1).toIntArray()
    var t = 0
    fun swap(n: Int) {
        val w = P[n]
        P[n] = P[n + 1]
        P[n + 1] = w
    }
    for (n in 0 until N - 1) {
        if (P[n] == n) {
            t += 1
            swap(n)
        }
    }
    val ans = t
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt(D: Int = 0) = listOfString().map { Integer.parseInt(it) + D }
fun listOfInt(vararg deltas: Int) = listOfString().map { Integer.parseInt(it) }.mapIndexed { index, int -> int + deltas[index % deltas.size] }
