import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int k, string s) {
    int n = cast(int)s.length;
    int score = 0;
    for (int i = 0; i < n - 1; i++) {
        if (s[i] == s[i+1]) score++;
    }
    int ans = min(score + 2 * k, n - 1);
    return ans;
}

void main() {
    int n, k; scan(n, k);
    string s = read!string;
    writeln(calc(k, s));
}
