문제
Farmer John has
Over the course of the day, each cow writes down a list of cows. Specifically, cow i's list contains the range of cows starting with herself (cow
FJ has recently discovered that each breed of cow has exactly one distinct leader. FJ does not know who the leaders are, but he knows that each leader must have a list that includes all the cows of their breed, or the other breed's leader (or both).
Help FJ count the number of pairs of cows that could be leaders. It is guaranteed that there is at least one possible pair.
입력
The first line contains
The second line contains a string of length
The third line contains
출력
Output the number of possible pairs of leaders.
예제1
4
GHHG
2 4 3 4
1
예제2
3
GGH
2 3 3
2