T=int(input()) for tests in range(T): S=input() W=0 G=0 R=0 flag=1 for s in S: if s=="G": G+=1 elif s=="R": R+=1 else: W+=1 if G