import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    var (_, k) = readIntegerList()
    val s = readLine()!!
    val runLength = runLengthEncode(s)
    var unHappy = 0
    for (i in 1..runLength.lastIndex) {
        if (runLength[i].value == 'L' && runLength[i - 1].value == 'R') {
            unHappy += 2
        }
    }

    var edge = 0
    if (runLength.first().value == 'L') {
        edge++
    }

    if (runLength.last().value == 'R') {
        edge++
    }

    while (k > 0 && unHappy > 0) {
        unHappy -= 2
        k--
    }

    if (k >= 1) {
        edge = 1
    }

    println(s.length - unHappy - edge)
}


data class RunLength<T>(val value: T, val length: Int)

/** O(s.length) */
fun runLengthEncode(s: CharSequence): List<RunLength<Char>> {
    if (s.isEmpty()) return emptyList()

    val runLengthList = mutableListOf<RunLength<Char>>()
    var currentChar = s.first()
    var length = 1
    for (c in s.substring(1)) {
        if (c == currentChar) {
            length++
        } else {
            runLengthList += RunLength(currentChar, length)
            currentChar = c
            length = 1
        }
    }
    runLengthList += RunLength(currentChar, length)

    return runLengthList
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)
