N,K=gets.split.map(&:to_i)
S=gets.strip
cnt=0
seq=0
cur=S[0]
for i in 0..S.size-1
    seq+=1
    if S[i]!=cur
        cnt+=seq-1
        seq=0
        cur=S[i]
    end
end
cnt+=seq-1
puts [S.size-1,cnt+K*2].min
