No.436 ccw
Problem Statement
C has a string S.
The string S has the form "c...ccw...w". That is, from the left, two or more c's are lined up, followed by one or more w's.
C wants S not to contain the substring "ccw" (not "cww"). To achieve this, C repeats the following operation.
Operation: Delete one character at the left end or the right end of S.
What is the minimum number of operations C must perform?
Input
S
The input consists of the string $S$ on a single line.
The length of the string $S$ is at least 3 and at most 100000 characters.
The string $S$ consists of two or more c's from the left, followed by one or more w's.
Output
Output on a single line the minimum number of operations C must perform.
Print a newline at the end.
Sample
Sample 1
Input
cccwwwwww
Output
2
Deleting the left end twice gives "cwwwwww", which no longer contains "ccw".
Sample 2
Input
ccccccccwww
Output
3
Deleting the right end three times gives "cccccccc", which no longer contains "ccw".
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
🍡yurahuna
moti