n,k = gets.chomp.split.collect{ |item| item.to_i}
s = gets.chomp
s.insert(0,"R")
s += "L"

def check(arr,i)
  if(arr[i] == "R")
  return (arr[i] == arr[i+1])
  else
    return (arr[i] == arr[i-1])
  end
end

ans = n
badn = 0
1.upto(n) do |ni|
  badn += 1 if check(s,ni) == false
end
ans -= [1,(badn - 2*k)].max

puts ans
