/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
6 1
LRLRRL
---+/
/+---test
13 3
LRRLRLRRLRLLR
---+/
/+---test
10 1
LLLLLRRRRR
---+/
/+---test
9 2
RRRLRLRLL
---+/

void rev(ref char[] str, size_t l, size_t r) {
  foreach (i; 0..(r-l)/2+1) swap(str[l+i], str[r-i]);

  foreach (ref c; str[l..r+1]) c = (c == 'L'? 'R': 'L');
}

void main(string[] args) {
  long N, K;
  readf(" %d %d ", &N, &K);
  auto S = ['R']~readln.chomp.to!(char[])~"L";

  size_t[] b2b;
  size_t[] f2f;


  foreach (k; 0..K) {
    size_t l, r;
    foreach (i; 1..S.length-2) {
      if (S[i] == 'R' && S[i+1] == 'L') {
        l = i; break;
      }
    }
    foreach_reverse (i; 1..S.length-2) {
      if (S[i] == 'L' && S[i+1] == 'R') {
        r = i; break;
      }
    }

    if (l == 0 && r == 0) break;

    if (l > r) swap(l, r);
    S.rev(l+1, r);
  }

  long ans = S.length-2;
  foreach (i; 1..S.length-1) {
    if ((S[i-1] == 'R' && S[i]   == 'L') || (S[i]   == 'R' && S[i+1] == 'L')) --ans;
  }
  ans.writeln;
}
