A string is a sequence of characters.
A subsequence is obtained by deleting some elements from a sequence
without changing the order of the remaining elements.
For example, ace
and de
are subsequences of abcdef
.
You are given a string $ S = s_1 s_2 \cdots s_n $ which only contains
the characters s
and u
.
A subsequence of $ S $ is said to be suspicious if it has a length of 3
and it is equal to the string sus
.
Count the number of suspicious subsequences (a.k.a. susequences).
Two subseqeunces are different if there is an index $ k $ such that $ s_k $ is present in only one of the subsequences.
Input
The only line of input contains the string $ S $.
Output
Output the number of suspicious subsequences.
Constraints
Subtask 1 (30%): $1 \le n \le 100$
Subtask 2 (30%): $1 \le n \le 5000$
Subtask 3 (40%): $1 \le n \le 10^6$
Sample Test Cases
Input | Output | |
---|---|---|
susus | 4 | |
The suspicious subsequences are $ s_1 s_2 s_3, s_1 s_2 s_5, s_1 s_4 s_5 $ and $ s_3 s_4 s_5 $. |
Scoring: Per Subtask
Authored by s16f22
Appeared in 2024 Mini Contest 1