单点时限: 1.0 sec
内存限制: 256 MB
Given a string $S$ only contains lower-case Latin letters, you can perform the following operations on $S$ any number of times:
Select a non-empty contiguous substring of $S$ and replace the current character with its next character, specifically, when the current character is z
, replace it with a
.
For example: abcabc
, choose the interval $[1,6]$ and the result of one operation is bcdbcd
.
Your goal is to find the minimum number of operations required to make $S$ contains only one type of lower-case Latin letter.
Restriction: The number of operations on each position can not exceed 25.
A string $S\ (|S|\le 10^5)$ as required.
Output one number — the minimum number of operations required to make $S$ contains only one type of lower-case Latin letter.
abc
2
abz
3