Score : $400$ points
We have a string $S$ of length $N$ consisting of R, G, and B.
Find the number of triples $(i,~j,~k)~(1 \leq i < j < k \leq N)$ that satisfy both of the following conditions:
R, G, and B.Input is given from Standard Input in the following format:
$N$ $S$
Print the number of triplets in question.
4 RRGB
1
Only the triplet $(1,~3,~4)$ satisfies both conditions. The triplet $(2,~3,~4)$ satisfies the first condition but not the second, so it does not count.
39 RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB
1800