题目描述
Problem Description
Little C's computer science teacher has assigned him a task, which is as follows:
There is a string containing uppercase and lowercase letters and digits. You can change any character to another character. If the ASCII code of the character before the change is $a$ and the ASCII code after the change is $b$, then this change consumes $|a-b|$ time. You need to transform the entire string into a string that only contains uppercase letters.
Little C has many other important assignments in subjects like Chinese, math, and English. To save time, you need to calculate the minimum time Little C needs to transform the string into one that only contains uppercase letters.
Input Format
A single line containing a string $s$ representing the string given by the teacher.
Output Format
A single line containing a non-negative integer $t$, representing the minimum time required to transform the string into one that only contains uppercase letters.
Sample Input and Output
Sample Input #1
AA0aa
Sample Output #1
31
Sample Input #2
3kyOu
Sample Output #2
89
Notes
Sample Explanation
For the first sample, the best approach is to transform it into AAAZZ, which results in a cost of $0+0+|48-65|+|97-90|+|97-90|=31$. It is easy to prove that there is no better solution.
Where $48$ is the ASCII code of character 0, $65$ is the ASCII code of character A, $90$ is the ASCII code of character Z, and $97$ is the ASCII code of character a.
Data Range
This problem has subtasks.
Let $len$ be the length of string $s$.
| Subtask | Score | $\le$ |
|---|---|---|
| $0$ | $10$ | $3$ |
| $1$ | $30$ | $10$ |
| $2$ | $60$ | $10^5$ |
For all data, it is guaranteed that $1 \le len \le 10^5$, and $s$ contains only uppercase and lowercase letters and digits.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分