D. Make Them Equal
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a string $$$s$$$. You can perform the following operation:

  • Choose a letter $$$c$$$ and find all its occurrences in $$$s$$$. Let these occurrences be $$$p_1, \dots, p_m$$$. You cyclically increase the letters at those positions by one. The cost of this operation is $$$p_m - p_1$$$.

Your task is to make all the letters equal, achieving the minimal total cost.

Input

The first line contains a single integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) — the length of the string.

The second line contains $$$s_1, \dots, s_n$$$. The letters are lowercase English alphabet characters.

Output

Output the minimal total cost.

Examples
Input
5
azabz
Output
3
Input
4
abca
Output
0
Input
8
baknsasn
Output
52
Input
10
bcforobxgf
Output
54
Note

You can perform the following operations to achieve the optimal answer:

  • $$$aza\color{orange}bz \rightarrow aza\color{orange}cz$$$, the cost is $$$0$$$.
  • $$$aza\color{orange}cz \rightarrow aza\color{orange}dz$$$, the cost is $$$0$$$.
  • ...
  • $$$aza\color{orange}yz \rightarrow aza\color{orange}zz$$$, the cost is $$$0$$$.
  • $$$a\color{orange}za\color{orange}z\color{orange}z \rightarrow a\color{orange}aa\color{orange}a\color{orange}a$$$, the cost is $$$3$$$, because the occurrences of $$$\color{orange}z$$$ are $$$\{2, 4, 5\}$$$ and the cost is $$$5 - 2$$$.

The total cost is $$$3$$$.