fun calc(n:Int, m:Int): Int {
    if (n <= 0)  return 0
    return n/m + if(n%m!=0) 1 else 0
}

fun main(args: Array<String>) {
    val (N,K) = readLine()!!.split(" ").map { it.toInt() }
    val a = readLine()!!.split(" ").map{it.toInt()}

    val pos = a.indexOf(1)
    val left = pos
    val right = a.size - left - 1

    val cnt = (0 until K).map {
        val l = left - it
        val r = right - (K-1-it)

        val lc = calc(l,K-1)
        val rc = calc(r,K-1)

        lc + rc + 1
    }.min()

    println(cnt)
}