Author: | N. Grebenyuk | Time limit: | 1 sec | |
Input file: | Standard input | Memory limit: | 256 Mb | |
Output file: | Standard output |
Anastasia is standing in the beginning of a string (at the first letter), consisting of N lowercase Latin letters. She can make unlimited number of jumps to the next letter in the string. She also can make at most one hyperjump to any letter that is standing in alphabet later than the current letter. For example, if Anastasia is standing at letter 'x', she can jump to any of letters 'y' and 'z' in the string.
Anastasia is a very curious girl. She is interested what is the minimal number of jumps (a hyperjump is also counted as an one jump) she needs to reach the last letter (the letter number N).
The first line contains an integer N — number of letters in the string.
Second line contains string consisting of N lowercase Latin letters.
Print one integer — the minimal amount of jumps Anastasia needs to reach the last letter.
2 ≤ N ≤ 105
No. | Standard input | Standard output |
---|---|---|
1 |
|
|
2 |
|
|
3 |
|
|