시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 (추가 시간 없음) 1024 MB (추가 메모리 없음)140877163.964%

문제

Yunee is studying English vocabulary. Among many words that Yunee has learned, "success" is Yunee's favorite word and "failure" is Yunee's least favorite word.

Yunee noticed that two identical characters appear in a row in the word "success" but not in the word "failure." So Yunee decided to call a string "successful string" when it has a property of the word "success." Formally, a string $S$ is a successful string when there is a position $i$ such that $S_i = S_{i+1}$. Here $S_i$ denotes the $i$-th character of $S$.

Yunee wants to count how many successful strings there are among the substrings of a given string. Help Yunee write a program that counts the number of successful substrings. You have to consider two substrings distinct when their positions are different, even if the two strings are the same.

입력

The first line contains an integer $N$ that represents the length of a string. $(1 \leq N \leq 10^6)$

The second line contains a string of length $N$ consisting of lowercase alphabets.

출력

Output the number of successful strings among the substrings of the given string.

예제 입력 1

7
success

예제 출력 1

15

"ucc", "ccess", "ss" are examples of successful substrings of the string "success". On the other hand, "scc" is not a successful substring, because it is not a substring of "success" even though it is a successful string.

예제 입력 2

7
failure

예제 출력 2

0

예제 입력 3

4
aaaa

예제 출력 3

6

출처

University > UNIST > 3rd UNIST Algorithm Programming Contest Uni-CODE 2021 C번