luogu#P16602. [SYSUCPC 2025] SYSU II

[SYSUCPC 2025] SYSU II

Problem Description

As you all know, you are participating in the SYSUCPC (SYSU Counting Periodic-string Contest) finals.

A string is considered good\bf{good} if and only if it can be rearranged into a perfectly periodic string with sysu\texttt{sysu} as its period (which means several sysu\texttt{sysu} repetitions). For example, sysu,yssu,ssyyssuu\texttt{sysu,yssu,ssyyssuu} are all good\bf{good}, while ussu, sysusys\texttt{ussu, sysusys} are not. Given a string SS, determine how many of its substrings are good\bf{good}.

A string aa is a substring of a string bb if aa can be obtained from bb by the deletion of several (possibly zero or all) characters from the beginning and several (possibly zero or all) characters from the end.

Input Format

The only line contains a single string S(4S2×105)S(4\le |S|\le 2\times 10^5). It is guaranteed that SS only contains lowercase English letters.

Output Format

An integer, representing the number of good\bf{good} substrings of SS.

ilovesysusysu
6

Hint

There are 66 good\bf{good} substrings : sysu,ysus,susy,usys,sysu,sysusysu\texttt{sysu,ysus,susy,usys,sysu,sysusysu}.