import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}

func main() {
    var nk = readWords { Int($0)! }.makeIterator()
    let n = nk.next()!
    let k = nk.next()!

    // 13 5
    // LRRLRLRRLRLLR
    // LRRLRLLLLRLLR
    // LRRLRRRRRRLLR
    // LRRLLLLLLLLLR
    // LRRRRRRRRRRRR (if LLRLLLLLLLL... then +1)

    let S = Array(readLine()!)
    var count = 0
    for i in 0..<n-1 {
        if S[i] == S[i+1] {
            count += 1
        }
    }

    print(min(count+k*2, n - 1))
}

main()