// problem name is- Testing Robot
/* package codechef; // don’t place package name! */
import java.util.;
import java.lang.;
import java.io.*;
/* Name of the class has to be “Main” only if the class is public. */
class Codechef
{
public static void main (String args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t–>0)
{
int n=sc.nextInt(), x=sc.nextInt(), maxmoves=n+x+1, fre=new int[maxmoves], fre_neg=new int[maxmoves], count=0;
String s=sc.next();
fre++;
for(int i=0;i<n;i++)
{
char ch=s.charAt(i);
if(ch==‘R’)
{
fre[++x]++;
}
else if(ch=='L' && --x<0)
{
fre_neg[Math.abs(x)]++;
}
else
{
fre[x]++;
}
}
for(int i=0;i<maxmoves;i++)
{
if(fre[i]!=0)
{
count++;
}
}
for(int i=0;i<maxmoves;i++)
{
if(fre_neg[i]!=0)
{
count++;
}
}
System.out.println(count);
}
}
}