import scala.util.control.Breaks._
import scala.math.min

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n, k = sc.nextInt
    // val as = List.fill(n)(sc.nextLong)

    var i = 0
    breakable(while(true) {
      if(sc.nextInt == 1) break
      i += 1
    })

    val l = (i + i % 2) / 2
    val r = (n - i - 1 + (n - i - 1) % 2) / 2

    println(
       l + r - (if(min(i, n - i) == 1) 1 else 0)
    )
  }
}