Playf has a string $$$S$$$ with length $$$n$$$, which only contains three types of letters A, B, and C. She wants to find some triples $$$(i, j, k)$$$ where $$$0 \le i \lt j \lt k \lt n$$$, such that $$$\overline{S_iS_jS_k}=ABC$$$ or $$$\overline{S_iS_jS_k}= CBA$$$. But Playf does not want each character to be used repeatedly, so the index of each character appears in at most one triple.
Playf wants to know how many triples she can find at most, please help her.
The first line contains a string $$$S (1\le |S| \le 3\times 10^5)$$$.
Print an integer, the maximum number of triples Playf can find.
ABCBBAC
2
ABCBBACCA
2
BACABA
1
For the first example, two triples are (0,1,6) and (2,3,5). There might be other set of two triples, but Playf can not find more than 2 triples in this example.
| Name |
|---|


