#include //#include //#include #define FOR(i, a, b) for(int i = a; i < b; i++) #define REP(i, n) FOR(i, 0, n) #define MOD 1000000007 #define INF 2000000000 typedef long long ll; typedef unsigned long long ull; //typedef Pair P; using namespace std; int main(void){ int T; cin >> T; REP(i,T){ string S; cin >> S; int numWG = 0; int numGR = 0; bool flag = false; REP(j, S.length()){ if(S[j]=='W'){ numWG++; }else if(S[j]=='G'){ numWG--; numGR++; }else{ numGR--; } //cout<