(n,k)=gets.split.map(&:to_i)
s=gets.chars


lr= s.each_cons(2).select{|ss| ss==["L","R"] }.size
rl= s.each_cons(2).select{|ss| ss==["R","L"] }.size
h0=s.each_cons(2).select{|a,b| a==b }.size

p h0+[lr,k].min + [rl,k].min