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


    var A = mutableListOf<Int>()


    var prev = ' '
    S.forEach { c ->
        if (prev == c) {
            A[A.size - 1]++
        } else {
            A.add(1)
        }
        prev = c
    }
    val new = mutableListOf<Int>()

    var sum = 0
    (0 until Math.min(2*K + 1, A.size)).forEach {
        sum += A[it]
    }
    new.add(sum)
    (2*K + 1 until A.size).forEach {
        new.add(A[it])
    }
    print(new.sum() - new.size)
}