#include using namespace std; #define all(v) v.begin(),v.end() using ll = long long; using ull = unsigned long long; using vll=vector; using vvll = vector>; int main(){ ll T; cin>>T; while(T--){ string S; cin>>S; ll N=S.size(); bool a=true; bool b=false; for(int i=N-1;i>=0;i--){ if(S[i]=='W')a=false; if(S[i]=='G'){ if(!b)a=false; break; } if(S[i]=='R') b=true; } ll g=0; for(int i=0;i