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

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 r = n - i - 1
    println(
      if(i <= k) 1 + ceil((n - i - 1 - (k - i - 1)) / 2.0).toInt
      else if(r <= k) 1 + ceil((i - 1 - (k - r - 1)) / 2.0).toInt
      else {
        ceil(i / 2.0).toInt + ceil(r / 2.0).toInt
      }
    )
  }
}