import std.stdio, std.string, std.conv, std.algorithm;

void main() {
    int[] tmp = readln.chomp.split.to!(int[]);
    int n = tmp[0], k = tmp[1];
    string s = readln.chomp;
    int cnt;
    foreach (i; 1 .. n) {
        if (s[i] == s[i-1]) ++cnt;
    }
    min(n-1, cnt+2*k).writeln;
}