Codeforces Round 352 (Div. 2)
B
Different is Good
Codeforces
1000
原题
← AC →
翻译中…

A wise man told Kerem "Different is good" once, so Kerem wants all things in his life to be different.

翻译中…

Kerem recently got a string $*s*$ consisting of lowercase English letters. Since Kerem likes it when things are different, he wants all substrings of his string $*s*$ to be distinct. Substring is a string formed by some number of consecutive characters of the string. For example, string "aba" has substrings "" (empty substring), "a", "b", "a", "ab", "ba", "aba".

翻译中…

If string $*s*$ has at least two equal substrings then Kerem will change characters at some positions to some other lowercase English letters. Changing characters is a very tiring job, so Kerem want to perform as few changes as possible.

翻译中…

Your task is to find the minimum number of changes needed to make all the substrings of the given string distinct, or determine that it is impossible.

翻译中…

Input

翻译中…

The first line of the input contains an integer $*n*$ ($1 ≤ *n* ≤ 100 000$) — the length of the string $*s*$.

翻译中…

The second line contains the string $*s*$ of length $*n*$ consisting of only lowercase English letters.

翻译中…

Output

翻译中…

If it's impossible to change the string $*s*$ such that all its substring are distinct print -1. Otherwise print the minimum required number of changes.

翻译中…

Note

翻译中…

In the first sample one of the possible solutions is to change the first character to 'b'.

翻译中…

In the second sample, one may change the first character to 'a' and second character to 'b', so the string becomes "abko".

翻译中…

样例

Input #1
2
aa
Output #1
1
InputCopy OutputCopy
Input #2
4
koko
Output #2
2
InputCopy OutputCopy
Input #3
5
murat
Output #3
0
InputCopy OutputCopy
题目信息
题号
672B
时间限制
2 s
内存限制
256 MB
标签
构造
模拟
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。