아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Successful String

면접 대비

시간 제한1초메모리 제한1024 MB

요약
주어진 문자열의 부분 문자열 중 인접한 두 문자가 같은 위치가 하나라도 있는 것의 개수를 센다.
난이도

보통10점 중 4점

유형
문자열, 조합론, 구현
정답자
아직 제출이 없습니다

문제

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 SS is a successful string when there is a position ii such that S_i=S_i+1S\_i = S\_{i+1}. Here S_iS\_i denotes the ii-th character of SS.

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 NN that represents the length of a string. (1≤N≤106)(1 \leq N \leq 10^6)

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

출력

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

예제3

  1. 예제 1

    입력
    7
    success
    
    예상 출력
    15
    
  2. 예제 2

    입력
    7
    failure
    
    예상 출력
    0
    
  3. 예제 3

    입력
    4
    aaaa
    
    예상 출력
    6