PivotOJ

Lonely Photo

시간 제한: 2000ms메모리 제한: 1024MB출처: USACO 2021 December BronzeBOJ 23878

문제

Farmer John has recently acquired NN new cows (3N5×105)(3 \le N \le 5 \times 10^5), each of whose breed is either Guernsey or Holstein.

The cows are currently standing in a line, and Farmer John wants take a photo of every sequence of three or more consecutive cows. However, he doesn't want to take a photo in which there is exactly one cow whose breed is Guernsey or exactly one cow whose breed is Holstein --- he reckons this singular cow would feel isolated and self-conscious. After taking a photo of every sequence of three or more cows, he throws out all of these so-called "lonely" photos, in which there is exactly one Guernsey or exactly one Holstein.

Given the lineup of cows, please help Farmer John determine how many lonely photos he will throw out. Two photos are different if they start or end at different cows in the lineup.

입력

The first line of input contains NN.

The second line contains a string of NN characters. The iith character is G if the iith cow in the line is a Guernsey. Otherwise, it will be an H and the iith cow is a Holstein.

출력

Please print the number of photos Farmer John will throw out because they are lonely.

예제

예제 1

입력
5
GHGHG
출력
3
코드를 제출하려면 로그인하세요.