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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * @author rozerhacks
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "rozerhacks", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            BChessCheater solver = new BChessCheater();
            int testCount = Integer.parseInt(in.next());
            for (int i = 1; i <= testCount; i++)
                solver.solve(i, in, out);
            out.close();
        }
    }

    static class BChessCheater {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            int k = in.readInt();
            char[] ar = in.readString().toCharArray();
            long ans = 0;
            boolean flag = false;
            for (int i = 0; i < n; i++) {
                if (ar[i] == 'W') {
                    flag = true;
                }
            }
            if (!flag) {
                if (k > 0)
                    out.println((2 * Math.min(n - 1, (k - 1)) + 1));
                else out.println(0);
                return;
            }
            BSTIntegerMulti[] bstIntegerMulti = new BSTIntegerMulti[3];
            for (int i = 0; i < 3; i++) bstIntegerMulti[i] = new BSTIntegerMulti();

            int lenAhead = 0;
            int lenLast = 0;
            int ct = 0;
            for (int i = 0; i < ar.length; ) {
                if (ar[i] == 'W') {
                    ans++;
                    if (i > 0 && ar[i - 1] == 'W') ans++;
                    i++;
                } else {
                    int j = i;
                    while (j < n && ar[j] == 'L') j++;
                    int how = 0;
                    if (i > 0 && ar[i - 1] == 'W') how++;
                    if (j < n && ar[j] == 'W') how++;
                    if (how == 1) {
                        ct++;
                        if (i == 0) lenAhead = j - i;
                        else lenLast = j - i;
                    }
                    bstIntegerMulti[how].insert(j - i, 1);
                    i = j;
                }
            }
            assert (ct == 2);
            while (k > 0 && bstIntegerMulti[2].getSize() > 0) {
                int len = bstIntegerMulti[2].get(0);
                bstIntegerMulti[2].remove(len, 1);
                if (k >= len) {
                    k -= len;
                    ans += (2 * len + 1);
                } else {
                    ans += 2 * k;
                    k = 0;
                }
            }
            if (lenLast > 0) {
                if (k >= lenLast) {
                    k -= lenLast;
                    ans += (2 * lenLast);
                } else {
                    ans += (2 * k);
                    k = 0;
                }
            }

            if (lenAhead > 0) {
                if (k >= lenAhead) {
                    k -= lenAhead;
                    ans += (1 + (2 * (lenAhead - 1))) + 1;
                } else if (k > 0) {
                    ans += 2 * k;
                    k = 0;
                }
            }

            out.println(ans);

        }

    }

    static class BSTIntegerMulti {
        final int DEFAULT_CAPACITY = 15;
        int[] value;
        int[] leftNode;
        int[] rightNode;
        int[] leftCount;
        int[] rightCount;
        int[] nodeCount;
        int[] height;
        int[] stack = new int[64];
        int cap;
        int nextFree;
        int root;
        int size;
        int stackPointer;

        public BSTIntegerMulti(int cap) {
            this.cap = 0;
            nextFree = 1;
            size = 0;
            resize(cap + 1);
        }

        public BSTIntegerMulti() {
            this.cap = 0;
            nextFree = 1;
            size = 0;
            resize(DEFAULT_CAPACITY);
        }

        private void resize(int newCap) {
            int[] newValue = new int[newCap];
            int[] newLeftNode = new int[newCap];
            int[] newRightNode = new int[newCap];
            int[] newNodeCount = new int[newCap];
            int[] newLeftCount = new int[newCap];
            int[] newRightCount = new int[newCap];
            int[] newHeight = new int[newCap];

            if (cap != 0) {
                System.arraycopy(value, 0, newValue, 0, cap);
                System.arraycopy(leftNode, 0, newLeftNode, 0, cap);
                System.arraycopy(rightNode, 0, newRightNode, 0, cap);
                System.arraycopy(nodeCount, 0, newNodeCount, 0, cap);
                System.arraycopy(leftCount, 0, newLeftCount, 0, cap);
                System.arraycopy(rightCount, 0, newRightCount, 0, cap);
                System.arraycopy(height, 0, newHeight, 0, cap);
            }
            value = newValue;
            leftNode = newLeftNode;
            rightNode = newRightNode;
            nodeCount = newNodeCount;
            leftCount = newLeftCount;
            rightCount = newRightCount;
            height = newHeight;
            cap = newCap;
        }

        private int newNode(int val, int count) {
            if (nextFree == cap) resize(cap << 1);
            value[nextFree] = val;
            leftNode[nextFree] = 0;
            rightNode[nextFree] = 0;
            leftCount[nextFree] = 0;
            rightCount[nextFree] = 0;
            nodeCount[nextFree] = count;
            height[nextFree] = 1;
            return nextFree++;
        }

        public void insert(int data, int count) {
            size += count;
            if (root == 0) {
                root = newNode(data, count);
                return;
            }
            int root = this.root;
            int stackPointer = 0;
            int recentChildren = -1;
            while (true) {
                if (value[root] == data) {
                    nodeCount[root] += count;
                    return;
                } else if (value[root] > data) {
                    stack[stackPointer++] = root;
                    leftCount[root] += count;
                    if (leftNode[root] == 0) {
                        recentChildren = leftNode[root] = newNode(data, count);
                        break;
                    }
                    root = leftNode[root];
                } else {
                    stack[stackPointer++] = root;
                    rightCount[root] += count;
                    if (rightNode[root] == 0) {
                        recentChildren = rightNode[root] = newNode(data, count);
                        break;
                    }
                    root = rightNode[root];
                }
            }

            while (stackPointer > 0) {
                int node = stack[--stackPointer];
                if (value[node] > data) leftNode[node] = recentChildren;
                else rightNode[node] = recentChildren;
                updateHeight(node);
                int diff = getDiff(node);
                if (diff > 1) {
                    if (data < value[leftNode[node]]) {
                        recentChildren = rightRotate(node);
                    } else {
                        leftNode[node] = leftRotate(leftNode[node]);
                        recentChildren = rightRotate(node);
                    }
                } else if (diff < -1) {
                    if (data > value[rightNode[node]]) {
                        recentChildren = leftRotate(node);
                    } else {
                        rightNode[node] = rightRotate(rightNode[node]);
                        recentChildren = leftRotate(node);
                    }
                } else {
                    recentChildren = node;
                }
            }
            this.root = recentChildren;
        }

        public void remove(int data, int count) {
            stackPointer = 0;
            root = remove(root, data, count);
        }

        private int remove(int curRoot, int data, int count) {
            if (curRoot == 0) return curRoot;
            int st = stackPointer;
            int recentChildren = -1;
            int root = curRoot;
            int pivot = -1;
            while (true) {
                if (value[root] == data) {
                    if (nodeCount[root] > count) {
                        size -= count;
                        nodeCount[root] -= count;
                        return curRoot;
                    } else if (nodeCount[root] == count) {
                        size -= count;
                        nodeCount[root] -= count;
                        if (leftNode[root] == 0 && rightNode[root] == 0) recentChildren = 0;
                        else if (leftNode[root] == 0) recentChildren = rightNode[root];
                        else if (rightNode[root] == 0) recentChildren = leftNode[root];
                        else {
                            pivot = root;
                            stack[stackPointer++] = root;
                            int min = minValue(rightNode[root]);
                            value[root] = value[min];
                            nodeCount[root] = nodeCount[min];
                            rightCount[root] -= nodeCount[min];
                            recentChildren = rightNode[root] = remove(rightNode[root], value[min], nodeCount[min]);
                            size += nodeCount[root];
                        }
                        break;
                    } else throw new RuntimeException("Removing more than present");
                } else if (value[root] > data) {
                    stack[stackPointer++] = root;
                    leftCount[root] -= count;
                    if (leftNode[root] == 0) break;
                    root = leftNode[root];
                } else {
                    stack[stackPointer++] = root;
                    rightCount[root] -= count;
                    if (rightNode[root] == 0) break;
                    root = rightNode[root];
                }
            }
            if (recentChildren == -1) {
                while (stackPointer > 0) {
                    int node = stack[--stackPointer];
                    if (value[node] > data) leftCount[node] += count;
                    else rightCount[node] -= count;
                }
                return curRoot;
            }
            while (stackPointer - st > 0) {
                int node = stack[--stackPointer];
                if (node != pivot)
                    if (value[node] > data) leftNode[node] = recentChildren;
                    else rightNode[node] = recentChildren;
                updateHeight(node);
                int diff = getDiff(node);
                if (diff > 1) {
                    if (getDiff(leftNode[node]) >= 0) {
                        recentChildren = rightRotate(node);
                    } else {
                        leftNode[node] = leftRotate(leftNode[node]);
                        recentChildren = rightRotate(node);
                    }
                } else if (diff < -1) {
                    if (getDiff(rightNode[node]) <= 0) {
                        recentChildren = leftRotate(node);
                    } else {
                        rightNode[node] = rightRotate(rightNode[node]);
                        recentChildren = leftRotate(node);
                    }
                } else {
                    recentChildren = node;
                }
            }
            return recentChildren;
        }

        private int minValue(int id) {
            while (leftNode[id] != 0) id = leftNode[id];
            return id;
        }

        private void updateHeight(int id) {
            height[id] = Math.max(height[leftNode[id]], height[rightNode[id]]) + 1;
        }

        private void updateCount(int id) {
            leftCount[id] = leftCount[leftNode[id]] + rightCount[leftNode[id]] + nodeCount[leftNode[id]];
            rightCount[id] = leftCount[rightNode[id]] + rightCount[rightNode[id]] + nodeCount[rightNode[id]];
        }

        private int rightRotate(int id) {
            int left = leftNode[id];
            int leftRight = rightNode[left];
            rightNode[left] = id;
            leftNode[id] = leftRight;
            updateHeight(id);
            updateCount(id);
            updateHeight(left);
            updateCount(left);
            return left;
        }

        private int leftRotate(int id) {
            int right = rightNode[id];
            int rightLeft = leftNode[right];
            leftNode[right] = id;
            rightNode[id] = rightLeft;
            updateHeight(id);
            updateCount(id);
            updateHeight(right);
            updateCount(right);
            return right;
        }

        private int getDiff(int id) {
            return height[leftNode[id]] - height[rightNode[id]];
        }

        public int get(int index) {
            int root = this.root;
            assert (root < size);
            while (root != 0) {
                if (leftNode[root] == 0) {
                    if (index - nodeCount[root] < 0)
                        return value[root];
                    else {
                        index -= nodeCount[root];
                        root = rightNode[root];
                    }
                } else {
                    if (index - leftCount[root] < 0) root = leftNode[root];
                    else if (index - leftCount[root] - nodeCount[root] < 0) return value[root];
                    else {
                        index -= (leftCount[root] + nodeCount[root]);
                        root = rightNode[root];
                    }
                }
            }
            throw new RuntimeException("BST out of index");
        }

        public int getSize() {
            return size;
        }

    }

    static class FastInput {
        private final InputStream is;
        private final StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private final byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public String next() {
            return readString();
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private final Writer os;
        private final StringBuilder cache = new StringBuilder(5 << 20);

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(long c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println(long c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}

