N,K = gets.split.map(&:to_i)
S = gets.chomp
s_split = []
point = 0
S.chars.each_with_index{|c,i|
  next if i == 0
  if S[i] != S[i-1]
    s_split << S[point..(i-1)]
    point = i
  end
}

if s_split.size <= 2*K
 puts S.length
end