input_lines = gets.chop.split.map(&:to_i)
input_lines2 = gets.chop.split("").map(&:to_s)

count = 0
n = input_lines[0]
k = input_lines[1]
firstC = input_lines2[0]
falseCount = 0
changeCount = 0

for i in 1...input_lines2.size
    if firstC != input_lines2[i]
        falseCount = falseCount + 1 
    else
        if falseCount > 1
            if changeCount != k 
                changeCount = changeCount + 1
                
                for j in 0...falseCount
                    input_lines2[i - j] = input_lines2[i - j] == "L" ? "R" : "L"
                end
            end
        end
        falseCount = 0
    end

end

if falseCount != 0 
    if changeCount != k 
        for j in 0...falseCount
            input_lines2[i - j] = input_lines2[i - j] == "L" ? "R" : "L"
        end
    end
    falseCount = 0
end


for i in 0...input_lines2.size

    if (i == 0 && input_lines2[0] == "L") || (i == input_lines2.size - 1 && input_lines2[input_lines2.size - 1] == "R")
        next
    end
    if input_lines2[(i - 1)] == "L" && input_lines2[i]  == "L"
        count =  count + 1 
    elsif (i + 1) != input_lines2.size
        if input_lines2[(i + 1)] == "R" && input_lines2[i] == "R"
            count =  count + 1 
        end
    end
end
puts count