fun main(args: Array<String>){
	val array = readLine()!!.split(" ")
	val n = array[0].toInt()
	val k = array[1].toInt()
	val s = readLine()!!
	
	if( n < 2 )
		println(0)
	else{
		var happy = if(s[0] == 'R' && s[1] == 'R') 1 else 0
		happy += if(s[n-1] == 'L' && s[n-2] == 'L') 1 else 0
		if( 2 < n )
			for(i in 1..n-2)
				if( s[i] == 'R' && s[i+1] == 'R' || s[i] == 'L' && s[i-1] == 'L' )
					happy++
		
		println(happy + Math.min(n - happy - 1, 2 * k))
	}
}
