import java.util.*

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	val k = scanner.nextInt()
	val s = scanner.next()

	var init = 0
	var bef = ' '
	s.toCharArray().forEach { c ->
		if (bef==c) init++
		bef = c
	}
	val seps = n-init-1
	var ans = init
	if (k<=seps/2) ans += 2*k
	else ans += seps/2 + k

	println(Math.min(ans, n-1))
}