
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(w, h) = readLine.trim.split(' ').map(_.toInt)
  val n = readLine.trim.toInt
  val order = readLine.trim.split(' ').map(_.toInt == 0)
  var outside = 2 * w + h - 2
  var inside = outside - 4
  var count = 0
  for (isOutside ← order){
    if (isOutside) outside -= 1
    else inside -= 1
    if (isNeighbor(inside, outside)) count += 1

  }
  println(count)
  def isNeighbor(inside:Int, outside: Int): Boolean = {
    if (outside.isOutsideBottom && inside.isInsideBottom) outside.outsideBottomPosition == inside.insideBottomPosition
    else if (outside.isOutsideRight && inside.isInsideRight) outside.outsideRightPosition == inside.outsideRightPosition
    else if (outside.isOutsideUp && inside.isInsideUp) outside.outsideUpPosition == inside.insideUpPosition
    else false
  }
  implicit class INT(val value: Int){
    def isOutsideBottom: Boolean = (1 to w).contains(value)
    def outsideBottomPosition: Int = value - 0
    def isOutsideRight: Boolean = (w to (w + h - 1)).contains(value)
    def outsideRightPosition: Int = value - w
    def isOutsideUp: Boolean = ((w + h - 1) to (2 * w + h - 2)).contains(value)
    def outsideUpPosition: Int = value - w - h + 1
    def isInsideBottom: Boolean = (1 to w - 1).contains(value)
    def insideBottomPosition: Int = value - 0
    def isInsideRight: Boolean = (w - 1 to (w + h - 4)).contains(value)
    def insideRightPosition: Int = value - w + 2
    def isInsideUp: Boolean = (w + h - 4 to 2 * w + h - 6).contains(value)
    def insideUpPosition: Int = value - w - h + 5
  }

  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}
