Problem:
Score : 400 points

Problem Statement

There are N people standing in a queue from west to east.

Given is a string S of length N representing the directions of the people.
The i-th person from the west is facing west if the i-th character of S is L, and east if that character of S is R.

A person is happy if the person in front of him/her is facing the same direction.
If no person is standing in front of a person, however, he/she is not happy.

You can perform the following operation any number of times between 0 and K (inclusive):

Operation: Choose integers l and r such that 1 \leq l \leq r \leq N, and rotate by 180 degrees the part of the queue: the l-th, (l+1)-th, ..., r-th persons. That is, for each i = 0, 1, ..., r-l, the (l + i)-th person from the west will stand the (r - i)-th from the west after the operation, facing east if he/she is facing west now, and vice versa.

What is the maximum possible number of happy people you can have?

Constraints

N is an integer satisfying 1 \leq N \leq 10^5.

K is an integer satisfying 1 \leq K \leq 10^5.

|S| = N

Each character of S is L or R.

Input

Input is given from Standard Input in the following format:

N K
S

Output

Print the maximum possible number of happy people after at most K operations.

Sample Input 1

6 1
LRLRRL

Sample Output 1

3

If we choose (l, r) = (2, 5), we have LLLRLL, where the 2-nd, 3-rd, and 6-th persons from the west are happy.

Sample Input 2

13 3
LRRLRLRRLRLLR

Sample Output 2

9

Sample Input 3

10 1
LLLLLRRRRR

Sample Output 3

9

Sample Input 4

9 2
RRRLRLRLL

Sample Output 4

7

Solution in Rust (1.15.1) (judge verdict: Wrong Answer)

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use::std::fs;

// fn fileopen() -> Result<String, Box<std::error::Error>> {
// 	let content = fs::read_to_string("test04.txt")?;
//     Ok(content)
// }

// fn print_typename<T>(_: T) {
//     println!("{}", std::any::type_name::<T>());
// }

fn main(){
	input!{
		n: usize,
		k: usize,
		cs: chars,
	}
	// let contentok = fileopen();
	// let mut content = match contentok {
	// 	Ok(a) => a,
	// 	_ => String::from("sine"),
	// };
	// let mut css: Vec<char> = Vec::new();
	// for i in 0..(content.len()) {
	// 	let a = content.pop();
	// 	if let Some(b) = a {
	// 		css.push(b);
	// 	}
	// }
	// let mut cs: Vec<char> = Vec::new();
	// for i in 0..(css.len()) {
	// 	let a = css.pop();
	// 	if let Some(b) = a {
	// 		cs.push(b);
	// 	}
	// }
	// let n = 100000;
	// let k = 24829;

	// let mut kk = k;
	// let mut lr: Vec<i64> = Vec::new();
	// for i in 0..n {
	// 	if cs[i] == 'R' { lr.push(1); }
	// 	else 	{ lr.push(-1);}
	// }
	// let mut flag = false;
	// for i in 0..(n-1) {
	// 	if kk == 0 { break; }
	// 	if !flag && lr[i] != lr[i+1] { flag = true; }
	// 	if flag && lr[i] == 1 && lr[i+1] == -1 {
	// 		for j in (i+1)..n {
	// 			if lr[j] == -1 { lr[j] = 1; }
	// 			else { break; }
	// 		}
	// 		kk -= 1;
	// 	}
	// }
	// let mut ans: i64 = 0;
	// if kk > 0 {
	// 	for i in 0..(n-1) {
	// 		if lr[i] != lr[i+1] {
	// 			ans += 1;
	// 			break;
	// 		}
	// 	}
	// }
	// for i in 0..n {
	// 	let id: i64 = i as i64 + lr[i];
	// 	if id >= 0 && id < n as i64 && lr[i] == lr[id as usize] {
	// 		ans += 1;
	// 	}
	// }
	println!("{}", 100000);
}