#include<iostream>
#include<string>
#include<cmath>
using namespace std;


int main(){
	long i,N,K;
	char c1,c2;
	string S;
	i=N;
	long count=0;
	cin>>N>>K;
	while(c1=cin.get()=='\n');
	c1=cin.get();
	while(i){
		c2=cin.get();
		if(c2==c1)
			count++;
		c1=c2;
		i--;
	}
	cout<<min(2*K+count,N-1);
}