P12672 「LAOI-8」We noticed some websites spreading misinformation recently
Background

Some websites have disseminated misleading claims using labels like "official contest" and "GESP mock contest", causing confusion among students and parents.
Description
As a law-abiding Luogu user, we support only authentic contests.
You are given $T$ contest names (strings containing only letters and digits), which may not follow standard naming conventions. You can perform a swap between any two characters per operation. Your goal is to eliminate any case where both substrings `LGR` and `CSP` coexist in the same string.
For example, `LGRCSP` can be transformed in one move to `LGRSCP`.
Output the minimum number of operations required to eliminate this conflict.
Input Format
The first line contains a single integer $T$, the number of test cases.
Each of the next $T$ lines contains one string $s$, the contest name.
Output Format
For each test case, output a single integer — the minimum number of swaps required.
Explanation/Hint
**Subtasks are used in this problem.**
Let $t$ be the length of string $s$.
|Subtask|$t$|Score|
|:-:|:-:|:-:|
|$1$|$\le 10^3$|$40$|
|$2$|$\le 10^5$|$60$|
For all test cases, it is guaranteed that $1\le T \le 10$, $1 \le t \le 10^5$.