Four-Paw Chase
Gats oversees rooms connected by bidirectional passages. The rooms are numbered , and the passage network is connected and contains no cycles. Exactly one cat occupies each room, wearing a badge colored R, G, or B.
Let be the number of passages on the unique route between rooms and .
An unordered set of three cats forms a four-paw chase team if all of the following conditions hold:
- The team contains exactly one cat of each badge color.
- None of the three cats' rooms lies on the unique route between the rooms of the other two cats.
- If the red, green, and blue cats occupy rooms , , and , respectively, then
Count the number of four-paw chase teams.
Input
The first line contains an integer (), the number of rooms.
The second line contains a string of length . For each , the character is one of , , or , representing the badge color of the cat in room .
Output
Print one integer: the number of unordered sets of three cats that form a four-paw chase team.
Samples
Sample 1
Input
5 RRGBB 1 2 1 3 1 4 4 5
Output
1
The only valid team occupies rooms , , and . Its three pairwise distances total , which is divisible by .