A. Shustrik, Persik, and Eternal Friendship
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In an ancient temple, a legendary treasure is hidden, symbolizing the eternal friendship of the hamster Shustrik and the cat Persik. Shustrik and Persik want to show you this magical place. To get there, they need to open the gates of the ancient temple, which requires arranging a circular mosaic of sacred symbols (digits $$$0$$$-$$$9$$$) in the correct order.

The mosaic will be considered arranged in the correct order if the potential of the string of sacred symbols and the number of applications of the magical operation are minimized. The potential of a string is defined as the number of blocks of identical digits it consists of. For example, the potential of the string $$$112223$$$ is $$$3$$$, while for $$$12233321$$$ it is $$$5$$$. The magical operation that Shustrik and Persik can perform is as follows: they can cyclically shift the string to the right or left by $$$1$$$. Since the place is truly magical, the friends can perform this operation as many times as they want.

Help Shustrik and Persik calculate how many times they will have to apply the magical operation for the mosaic to be arranged in the correct order. Remember that the mosaic is considered arranged in the correct order only when both the potential of the string of sacred symbols and the number of applications of the magical operation are minimized.

Input

The first line contains a single integer $$$n$$$ ($$$1 \le n \le 10^{6}$$$).

The second line contains the string $$$s$$$ — the mosaic of sacred symbols.

Output

Output the number of magical operations that Shustrik and Persik will have to perform. If during the magical operations the friends shift to the left, output the number of magical operations with a negative sign «-» (without quotes); if to the right, output it without the negative sign «-».

Scoring
GroupPoints Additional constraints Required groups
120$$$n \le 8$$$
210$$$n \le 18$$$1
330$$$n \le 1\,000$$$1, 2
440No additional constraints1, 2, 3
Examples
Input
6
112223
Output
0
Input
9
112223111
Output
-2
Input
9
122333211
Output
-1
Note