Loading [MathJax]/jax/output/CommonHTML/jax.js

Problem A. Anastasia is jumping

Author:N. Grebenyuk   Time limit:1 sec
Input file:Standard input   Memory limit:256 Mb
Output file:Standard output  

Statement

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).

Input format

The first line contains an integer N — number of letters in the string.

Second line contains string consisting of N lowercase Latin letters.

Output format

Print one integer — the minimal amount of jumps Anastasia needs to reach the last letter.

Constraints

2N105

Sample tests

No. Standard input Standard output
1
6
badcab
2
2
10
edcbaedbca
5
3
26
zyxwvutsrqponmlkjihgfedcba
25

0.064s 0.008s 13