/* 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();
for(int i=0;i<t;i++){
int n=sc.nextInt();
String s=sc.next();
int p=0;
int q=0;
int r=0;
int m=0;
for(int j=1;j<=s.length();j++){
if(s.charAt(j)=='R')
{
p++;
}
else if(s.charAt(j)=='B')
{
q++;
}
else if(s.charAt(j)=='G')
{
r++;
}
if(p==n||q==n||r==n)
{
System.out.println("0");
}
else{
m=Math.max(p,Math.max(q,r));
System.out.println(n-m);
}
}
}
}
}