#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,k,count=0;
	cin>>n>>k;
	char c[n+2];
	int i;
	c[0]='R';
	c[n+1]='L';
	for(i=0;i<n;i++)cin>>c[i+1];
	for(i=1;i<n+1;i++){
		if(c[i]=='R'&&c[i+1]=='L')count++;
		if(c[i]=='L'&&c[i-1]=='R')count++;
	}
	cout<<min(n-count+2*k,n-1);
}