Ký tự xuất hiện nhiều lần

View as PDF

Submit solution

Points: 1.00
Time limit: 1.0s
Memory limit: 64M
Input: stdin
Output: stdout

Author:
Problem type

Cho dãy ký tự ~S~ chứa ~n \le 10^5~ ký tự thuộc tập ~\{'H', 'S', 'G' \}~. Đếm số dãy con ~S'~ của ~S~ sao cho trong ~S'~, số lượng ký tự mỗi loại ít nhất là ~2.~

Input

Một dòng duy nhất là chuỗi ký tự.

Output

Đáp số của bài toán.

Sample input

HHHSSSSGGG

Sample output

4

Giải thích

Có 4 chuỗi con thỏa mãn tính trong các vị trí: (2,11), (2, 12), (1,11), (1,12).


Comments

Please read the guidelines before commenting.


There are no comments at the moment.