#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+5;

int n,k,cnt;
string s;
int main(){
	cin>>n>>k>>s;
	cnt=n-1;
	for(int i=0;i<n-1;++i)if(s[i]!=s[i+1])cnt--;
	cout<<min(n-1,cnt+2*k)<<endl;
}