import scala.io.{StdIn => in}

object Main extends App {
  val n = in.readInt()
  val p = in.readLine.split(" ").map(_.toInt)

  val ans = p./:(0, 1, 0) { (e, i) =>
    val (acc, cnt, pre) = e
    if(i == cnt && pre == 0) (acc + 1, cnt + 1, i)
    else (acc, cnt + 1, 0)
  }._1

  println(ans)
}