N, K = gets.split(' ').map(&:to_i)
s = gets.chomp

s = 'R' + s + 'L'
happy = 0
1.upto(N) do |i|
	if (s[i] == 'L' && s[i-1] == 'L') ||
		(s[i] == 'R' && s[i+1] == 'R')
		happy += 1
	end
end
puts [happy+2*K, N-1].min