You like playing chess tournaments online.

In your last tournament you played n games. For the sake of this problem, each chess game is either won or lost (no draws). When you lose a game you get 0 points. When you win you get 1 or 2 points: if you have won also the previous game you get 2 points, otherwise you get 1 point. If you win the very first game of the tournament you get 1 point (since there is not a "previous game").

The outcomes of the n games are represented by a string s of length n: the i-th character of s is W if you have won the i-th game, while it is L if you have lost the i-th game.

After the tournament, you notice a bug on the website that allows you to change the outcome of at most k of your games (meaning that at most k times you can change some symbol L to W, or W to L). Since your only goal is to improve your chess rating, you decide to cheat and use the bug.

Compute the maximum score you can get by cheating in the optimal way.

Input

Each test contains multiple test cases. The first line contains an integer t (1≤ t ≤ 20,000) — the number of test cases. The description of the test cases follows.

The first line of each testcase contains two integers n, k (1≤ n≤ 100,000, 0≤ k≤ n) – the number of games played and the number of outcomes that you can change.

The second line contains a string s of length n containing only the characters W and L. If you have won the i-th game then s_i= W, if you have lost the i-th game then s_i= L.

It is guaranteed that the sum of n over all testcases does not exceed 200,000.

Output

For each testcase, print a single integer – the maximum score you can get by cheating in the optimal way.

Example

Input


8
5 2
WLWLL
6 5
LLLWWL
7 1
LWLWLWL
15 5
WWWLLLWWWLLLWWW
40 7
LLWLWLWWWLWLLWLWWWLWLLWLLWLLLLWLLWWWLWWL
1 0
L
1 1
L
6 1
WLLWLW


Output


7
11
6
26
46
0
1
6

Note

Explanation of the first testcase. Before changing any outcome, the score is 2. Indeed, you won the first game, so you got 1 point, and you won also the third, so you got another 1 point (and not 2 because you lost the second game).

An optimal way to cheat is to change the outcomes of the second and fourth game. Doing so, you end up winning the first four games (the string of the outcomes becomes WWWWL). Hence, the new score is 7=1+2+2+2: 1 point for the first game and 2 points for the second, third and fourth game.

Explanation of the second testcase. Before changing any outcome, the score is 3. Indeed, you won the fourth game, so you got 1 point, and you won also the fifth game, so you got 2 more points (since you won also the previous game).

An optimal way to cheat is to change the outcomes of the first, second, third and sixth game. Doing so, you end up winning all games (the string of the outcomes becomes WWWWWW). Hence, the new score is 11 = 1+2+2+2+2+2: 1 point for the first game and 2 points for all the other games.
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
 
public class Main {
	static final int INF = (int) (1e9 + 10);
	static final int MOD = (int) (1e9 + 7);
 
	// static final int N = (int) (4e5 + 5);
	// static ArrayList<Integer>[] graph;
	// static boolean visited[];
	// static long size[];
 
	public static void main(String[] args) throws NumberFormatException, IOException {
		FastReader sc = new FastReader();
		PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int t = sc.nextInt();
		while (t-- > 0) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            String ss= sc.next();
            char [] ch = ss.toCharArray();
            // int i =0 ; 
            int ii =0;
            int ans =0;
            while(ii < n){
                if(ch[ii] == 'W'){
                    ans++;
                    int jj = ii+1;
                    while(jj < n && ch[jj] == 'W'){
                        ans = ans +2;
                        jj++;
                    }
                    ii=jj;
                }else{
                    ii++;
                }
            }
            PriorityQueue<Integer> pq = new PriorityQueue<>();
            int i =0;
            int left =0;
            int right = 0;
            int li =0;
            int ri =-1;
            while(i < n ){
                if(ch[i] == 'L'){
                    int c =1;
                    int j = i+1 ; 
                    while(j < n && ch[j] == 'L'){
                        c++;
                        j++;
                    }
                    if(i ==0){
                        left = c;
                    }else if(i+c == n){
                        right = c;
                        ri = i;
                    }else{
                        pq.offer(c);    
                    }
                    
                    i = j;
                }else{
                    i++;
                }
            }
            int above =0;
            while(k > 0 && pq.size()> 0){
               int u = pq.poll();
               if(u > k ){
                   ans += k*2;
                   k =0;
               }else if(u == k){
                   ans += (2*k +1);
                   k =0;
               }else{
                   ans += ((u*2)+1);
                   k = k-u;
               }
            }
            if(k > 0){
                if(ri==0){
                    int m = Math.min(left , k);
                    ans += 1;
                    k = k-1;
                    ans += 2*k;
                }else{
                    int m = Math.min(right , k);
                    ans += 2*m;
                    k = k-m;
                    m = Math.min(left , k);
                    ans += 2*m;
                }
            }
            
            
            
            pr.println(ans);
            
            
		}
		pr.flush();
		pr.close();
	}
	static boolean pos(int m  , int k  , String s){
	   // int i =0 ;
	    int n = s.length();
	    int min =n;
	    int ac =0;
	    int bc =0;
	    for(int i = 0 ; i < m; i++){
	        if(s.charAt(i) == 'a')ac++;
	        else bc++;
	    }
	    min = Math.min((m-ac) , (m-bc));
	    int i = m;
	    int j =0;
	    while(i < n){
	        if(s.charAt(j) == 'a')ac--;
	        else bc--;
	        if(s.charAt(i) == 'a')ac++;
	        else bc++;
	        i++;
	        j++;
	        int tm = Math.min((m-ac) , (m-bc));
	        min= Math.min(min , tm);
	    }
	   // System.out.println(m+"---> " + min );
	    if(min <= k)return true;
	    return false;
	}
	
	static class Unionfind{
        private int count = 0;
        private int[] parent , rank;
        public Unionfind(int n ){
            count = n;
            parent =new int[n];
            rank =new int[n];
            for(int i = 0 ; i < n ; i++){
                parent[i] = i;
            }
        }
        public int find(int p){
            while(p != parent[p]){
                parent[p] = parent[parent[p]];
                p = parent[p];
            }
            return p;
        }
        public void union(int p , int q){
            int rootP = find(p);
            int rootQ= find(q);
            if(rootP == rootQ) return;
            if(rank[rootQ] > rank[rootP]){
                parent[rootP] = rootQ;
            }else{
                parent[rootQ] = rootP;
                if(rank[rootP]== rank[rootQ]){
                    rank[rootP]++;
                }
            }
            count--;
        }
        public int count(){
            return count;
        }
}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
    public static void dfsf(boolean [] vis , int u , ArrayList<ArrayList<Integer>> g){
        vis[u] = true;
        //yaha par har componet k element ka outut le sakte hai;
        for(int i = 0 ; i < g.get(u).size() ; i++){
            if(!vis[g.get(u).get(i)]){
                dfsf(vis , g.get(u).get(i) , g );
            }
        }
    }
    public static void dfsft(int i , boolean [] vis , Stack<Integer> stk , ArrayList<ArrayList<Integer>> adj){
        vis[i] = true;
        for(int j = 0 ; j < adj.get(i).size() ; j++){
            if(!vis[adj.get(i).get(j)]){
                dfsft(adj.get(i).get(j) , vis ,stk , adj);
            }
        }
        stk.push(i);
    }
    public static ArrayList<ArrayList<Integer>> transpose(ArrayList<ArrayList<Integer>> adj , int n){
        ArrayList<ArrayList<Integer>> g = new ArrayList<>();
        for(int i = 0 ; i <  n ; i++){
            g.add(new ArrayList<Integer>() );
        }
        for(int i = 0 ; i < n ; i++ ){
            for(int j = 0 ; j < adj.get(i).size() ; j++){
                g.get(adj.get(i).get(j)).add(i);
            }
        }
        return g;
    }
    
	/*
	 * Template From Here
	 */
	private static boolean possible(long[] arr, int[] f, long mid, long k) {
		long c = 0;
 
		for (int i = 0; i < arr.length; i++) {
			if ((arr[i] * f[f.length - i - 1]) > mid) {
				c += (arr[i] - (mid / f[f.length - i - 1]));
			}
		}
		// System.out.println(mid+" "+c);
		if (c <= k)
			return true;
		return false;
	}
 
	public static int lowerBound(ArrayList<Integer> array, int length, long value) {
		int low = 0;
		int high = length;
		while (low < high) {
			final int mid = (low + high) / 2;
			if (value <= array.get(mid)) {
				high = mid;
			} else {
				low = mid + 1;
			}
		}
		return low;
	}
 
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;
 
		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}
 
	static long gcd(long a, long b) {
		if (a == 0)
			return b;
		return gcd(b % a, a);
	}
 
	static long lcm(long a, long b) {
		return (a * b) / gcd(a, b);
	}
 
	public static void sortbyColumn(int[][] att, int col) {
		// Using built-in sort function Arrays.sort
		Arrays.sort(att, new Comparator<int[]>() {
 
			@Override
			// Compare values according to columns
			public int compare(final int[] entry1, final int[] entry2) {
 
				// To sort in descending order revert
				// the '>' Operator
				// if (entry1[col] > entry2[col])
				// return 1;
				// else //(entry1[col] >= entry2[col])
				// return -1;
				return new Integer(entry1[col]).compareTo(entry2[col]);
				// return entry1[col].
			}
		}); // End of function call sort().
	}
 
	static class pair {
		int V, I;
 
		pair(int v, int i) {
			V = v;
			I = i;
		}
	}
 
	public static int[] swap(int data[], int left, int right) {
		int temp = data[left];
		data[left] = data[right];
		data[right] = temp;
		return data;
	}
 
	public static int[] reverse(int data[], int left, int right) {
		while (left < right) {
			int temp = data[left];
			data[left++] = data[right];
			data[right--] = temp;
		}
		return data;
	}
 
	public static boolean findNextPermutation(int data[]) {
		if (data.length <= 1)
			return false;
 
		int last = data.length - 2;
		while (last >= 0) {
			if (data[last] < data[last + 1]) {
				break;
			}
			last--;
		}
		if (last < 0)
			return false;
 
		int nextGreater = data.length - 1;
		for (int i = data.length - 1; i > last; i--) {
			if (data[i] > data[last]) {
				nextGreater = i;
				break;
			}
		}
		data = swap(data, nextGreater, last);
		data = reverse(data, last + 1, data.length - 1);
		return true;
	}
 
	static long nCr(long n, long r) {
		if (n == r)
			return 1;
		return fact(n) / (fact(r) * fact(n - r));
	}
 
	static long fact(long n) {
		long res = 1;
		for (long i = 2; i <= n; i++)
			res = res * i;
		return res;
	}
 
	/*
	 * static boolean prime[] = new boolean[1000007];
	 * 
	 * public static void sieveOfEratosthenes(int n) {
	 * 
	 * for (int i = 0; i < n; i++) prime[i] = true; * for (int p = 2; p * p <=
	 * n; p++) { // If prime[p] is not changed, then it is a prime if (prime[p]
	 * == true) { // Update all multiples of p for (int i = p * p; i <= n; i +=
	 * p) prime[i] = false; } }
	 * 
	 * // Print all prime numbers // for(int i = 2; i <= n; i++) // { //
	 * if(prime[i] == true) // System.out.print(i + " "); // } }
	 */
 
	static long power(long fac2, int y, int p) {
		long res = 1;
		fac2 = fac2 % p;
		while (y > 0) {
			if (y % 2 == 1)
				res = (res * fac2) % p;
			fac2 = (fac2 * fac2) % p;
		}
		return res;
	}
 
	static long modInverse(long fac2, int p) {
		return power(fac2, p - 2, p);
	}
 
	static boolean isPrime(int n) {
		// Corner cases
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;
 
		// This is checked so that we can skip
		// middle five numbers in below loop
		if (n % 2 == 0 || n % 3 == 0)
			return false;
 
		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;
 
		return true;
	}
 
	public static BigInteger lcmm(String a, String b) {
		BigInteger s = new BigInteger(a);
		BigInteger s1 = new BigInteger(b);
		BigInteger mul = s.multiply(s1);
		BigInteger gcd = s.gcd(s1);
		BigInteger lcm = mul.divide(gcd);
		return lcm;
	}
 
}