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.


-----Examples-----
Input
2
aa

Output
1

Input
4
koko

Output
2

Input
5
murat

Output
0



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

Difficulty: EASY
Tags: String algorithms

Implementation

Constructive algorithms

Starter code:

Solutions:
n = int(input())
s = input()
z = set(s)
if n > 26:
	print('-1')
else:
	print(n - len(z))


inter = int(input())
inp = input()
if inter > 26:
	print(-1)
else:
	print(inter - len(set(inp)))


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	az = [0 for i in range(26)]
	cnt = 0
	for i in s:
		ind = ord(i) - 97
		az[ind] += 1
		if az[ind] > 1:
			cnt += 1
	print(cnt)


s = int(input())
a = input()
if s > 26:
	print(-1)
else:
	d = []
	i = 0
	while i < s:
		if a[i] not in d:
			d.append(a[i])
		i += 1
	print(len(a) - len(d))


t = int(input())
a = input()
l = []
f = list(set(a))
for i in f:
	l.append(a.count(i))
if len(a) < 27:
	print(sum(l) - len(f))
else:
	print(-1)


alth = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = input()
temp = [0] * 26
if n > 26:
	print(-1)
else:
	for i in s:
		temp[alth.find(i)] = 1
	print(n - sum(temp))


n = int(input().strip())
ll = input().strip()
if n <= 26:
	all = 'abcdefghijklmnopqrstuvwxyz'
	lll = [0] * 26
	for i in range(n):
		lll[all.find(ll[i])] += 1
	k = 0
	for i in lll:
		if i > 1:
			k += i - 1
	print(k)
else:
	print('-1')


import sys
n = int(input())
if n > 26:
	print('-1')
	sys.exit(0)
input_str = input()
res = 0
symbols = set()
for it in input_str:
	if it in symbols:
		res += 1
	else:
		symbols.add(it)
print(res)


n = int(input())
if n > 26:
	print(-1)
else:
	print(n - len(set(input())))


d = []
n = int(input())
L = sorted(input())
(lon, cont) = (0, 0)
for k in L:
	if lon == 0:
		d.append(k)
		lon += 1
	elif d[lon - 1] == k:
		cont += 1
	else:
		d.append(k)
		lon += 1
print([-1, cont][len(d) + cont <= 26])


import time
n = int(input())
s = input()
start = time.time()
if n < 27:
	d = {chr(ord('a') + i): 0 for i in range(26)}
	for i in s:
		d[i] += 1
	ans = 0
	for i in d.keys():
		if d[i] != 0:
			ans += d[i] - 1
	print(ans)
else:
	print(-1)
finish = time.time()


n = int(input())
s = input()
a = set(s)
x = n - len(a)
if n <= 26:
	print(x)
else:
	print(-1)


import string
import math
from collections import Counter

def array_int():
	return [int(i) for i in input().split()]

def vary(number_of_variables):
	if number_of_variables == 1:
		return int(input())
	if number_of_variables >= 2:
		return map(int, input().split())

def makedict(var):
	return dict(Counter(var))
mod = 1000000007
n = vary(1)
s = input()
st = makedict(list(s))
count = 0
pt = 0
for i in st:
	if st[i] > 1:
		count += st[i] - 1
	pt += 1
if count == 0:
	print(0)
elif pt >= 26:
	print(-1)
elif 1:
	if count > 26 - pt:
		print(-1)
	else:
		print(count)


input()
X = input()
N = len(X) - len(set(X))
print(N if N <= 26 - len(set(X)) else -1)


n = int(input())
a = list(input())
if n > 26:
	print(-1)
	exit(0)
else:
	print(len(a) - len(set(a)))


while 1:
	try:
		n = int(input())
	except:
		break
	s = input()
	if n > 26:
		print(-1)
		continue
	reps = [0] * 26
	for c in s:
		reps[ord(c) - ord('a')] += 1
	ans = 0
	for x in reps:
		if x > 1:
			ans += x - 1
	print(ans)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	dic = {}
	nr = 0
	for c in s:
		if dic.get(c) != None:
			nr += 1
		else:
			dic[c] = 1
	print(nr)


n = int(input())
l = input()
l = set(l)
print(n - len(l) if n < 27 else -1)


n = int(input())
s = input()
if len(s) - len(set(s)) >= 26 or len(s) > 26:
	print(-1)
else:
	print(len(s) - len(set(s)))


import math
import os
import random
import re
from sys import stdin, stdout
from collections import Counter

def si():
	return str(input())

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
n = ii()
s = si()
arr = set(s)
if n <= 26:
	print(n - len(arr))
else:
	print(-1)


from collections import defaultdict
d = defaultdict(lambda : 0)
n = int(input())
s = input()
count = 0
f = 1
for i in s:
	d[i] += 1
for i in range(n):
	if d[s[i]] > 1:
		f = 0
		for j in range(97, 123):
			if d[chr(j)] == 0:
				count += 1
				d[chr(j)] = 1
				d[s[i]] -= 1
				f = 1
				break
		if f == 0:
			break
print(-1 if f == 0 else count)


a = int(input())
b = set(list(input()))
if a > 26:
	print(-1)
else:
	print(a - len(b))


p = int(input())
a = list(input())
s = len(set(a))
if p == s:
	print(0)
elif p > 26:
	print(-1)
else:
	print(p - s)


n = int(input())
if n > 26:
	print(-1)
	exit(0)
print(n - len(set(input())))


import string

def solve(S):
	ans = 0
	if len(S) > 26:
		return -1
	for c in string.ascii_lowercase:
		x = S.count(c)
		if x > 0:
			ans += x - 1
	return ans
trash = input()
S = input()
print(solve(S))


n = int(input())
s = input()
diction = [0 for i in range(26)]
count = 0
if n > 26:
	print('-1')
else:
	for char in s:
		diction[ord(char) - 97] += 1
	for num in diction:
		if num > 1:
			count += num - 1
	print(count)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	d = dict()
	for i in range(len(s)):
		d[s[i]] = d.get(s[i], 0) + 1
	ans = 0
	for i in d:
		ans += d[i] - 1
	print(ans)


n = int(input())
s = input()
s1 = set(s)
cnt = len(s) - len(s1)
if len(s) > 26:
	print(-1)
else:
	print(cnt)


bu = [0] * 300
n = int(input())
palabra = input()
for i in range(len(palabra)):
	bu[ord(palabra[i]) - ord('a')] += 1
cont = 0
total = 0
for i in range(ord('z') - ord('a') + 1):
	if bu[i] == 0:
		cont += 1
	elif bu[i] > 1:
		total += bu[i] - 1
if total > cont:
	print('-1')
else:
	print(total)


n = int(input())
s = input()
print(len(s) - len(set(s)) if n < 27 else -1)


import sys
inp = sys.stdin.read().splitlines()
length = int(inp[0])
string = inp[1]
d = {}
if length > 26:
	print(-1)
else:
	for letter in string:
		if letter in d:
			d[letter] += 1
		else:
			d[letter] = 1
	print(sum(d.values()) - len(d))


n = int(input())
string = list(input())
if n > 26:
	print(-1)
else:
	res = 0
	chars = []
	for i in range(n):
		if string[i] not in chars:
			chars.append(string[i])
		else:
			res += 1
	print(res)


n = int(input())
st = input()
p = set(st)
count = 0
if n > 26:
	print(-1)
else:
	for i in p:
		x = st.count(i)
		count += x - 1
	print(count)


x = int(input())
s = [n for n in input()]
l = 0
if x > 26:
	print(-1)
else:
	for n in range(x):
		if s[n] != 0:
			for k in range(n + 1, x):
				if s[n] == s[k]:
					s[k] = 0
	j = x - s.count(0)
	if s.count(0) <= 26 - j:
		print(s.count(0))
	else:
		print(-1)


n = int(input())
if n > 26:
	print(-1)
	exit()
s = input()
w = set()
for i in range(n):
	w.add(s[i])
print(n - len(w))


def solve():
	n = int(input())
	if n > 26:
		return -1
	s = input().rstrip()
	S = set()
	res = 0
	for c in s:
		if c in S:
			res += 1
		else:
			S.add(c)
	return res
print(solve())


from sys import stdin

def main():
	n = int(stdin.readline())
	if n > 26:
		print(-1)
	else:
		word = stdin.readline()
		cnt = dict()
		for c in word:
			if c >= 'a' and c <= 'z':
				if c in cnt:
					cnt[c] += 1
				else:
					cnt[c] = 1
		ans = 0
		for k in cnt.keys():
			ans += cnt[k] - 1
		print(ans)
main()


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	a = [0] * 30
	for x in s:
		a[ord(x) - 97] += 1
	ans = 0
	for x in a:
		if x:
			ans += x - 1
	print(ans)


n = int(input())
s = str(input())
count = 0
if n > 26:
	print(-1)
else:
	l = [0] * 27
	for i in range(n):
		l[ord(s[i]) - 97] += 1
		if l[ord(s[i]) - 97] > 1:
			count += 1
	print(count)


n = int(input())
s = input()
dif = []
if n > 26:
	print(-1)
else:
	for i in s:
		dif.append(i)
	print(n - len(set(dif)))


n = int(input())
s = input()
d = {}
for i in s:
	if i in d:
		d[i] += 1
	else:
		d[i] = 1
count = 0
for i in d:
	if d[i] >= 2:
		count += d[i] - 1
if n > 26:
	print(-1)
else:
	print(count)


from string import *
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	ans = 0
	for i in ascii_letters:
		ans += s.count(i) - 1 if s.count(i) > 1 else 0
	print(ans)


import random
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	a = [0] * 26
	cnt = 0
	for i in range(n):
		if a[ord(s[i]) - ord('a')]:
			cnt += 1
		else:
			a[ord(s[i]) - ord('a')] = 1
	print(cnt)


a = input()
b = input()
if len(b) > 26:
	print(-1)
else:
	print(len(b) - len(set(b)))


n = int(input())
s = set(input())
ans = n - len(s)
if ans > 26 - len(s):
	print(-1)
else:
	print(ans)


from collections import defaultdict
d = defaultdict(int)
n = int(input())
c = input()
if n > 26:
	print(-1)
else:
	for char in c:
		d[char] += 1
	tot = 0
	for i in d.values():
		tot += i - 1
	print(tot)


n = int(input())
string = list(input())
conjunto = set()
count = 0
for i in range(n):
	if string[i] in conjunto:
		count += 1
	else:
		conjunto.add(string[i])
if len(set(string)) + count > 26:
	print(-1)
else:
	print(count)


n = int(input())
mp = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
ans = 0
q = str(input())
if len(q) == 0:
	s = str(input())
else:
	s = q
for i in range(len(s)):
	if mp[s[i]] == 0:
		mp[s[i]] += 1
	else:
		ans += 1
if n > 26:
	print(-1)
else:
	print(ans)


class CodeforcesTask672BSolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.word = ''

	def read_input(self):
		self.n = int(input())
		self.word = input()

	def process_task(self):
		if self.n > 26:
			self.result = '-1'
		else:
			self.result = str(self.n - len(set([ord(c) for c in self.word])))

	def get_result(self):
		return self.result
Solution = CodeforcesTask672BSolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


from collections import Counter
n = int(input())
s = input()
x = Counter(s)
c = 0
if n >= 27:
	print(-1)
else:
	for i in x.keys():
		if x[i] > 1:
			c += x[i] - 1
	print(c)


n = int(input())
s = input()
counter = -1
if len(s) <= 26:
	counter = 0
	for ch in s[:]:
		s = s[1:]
		if ch in s:
			counter += 1
print(counter)


n = input()
s = input()
d = []
j = 0
for i in s:
	if i not in d:
		d.append(i)
	else:
		j += 1
if len(d) + j > 26:
	print(-1)
else:
	print(j)


n = int(input())
a = input()
d = 0
b = [0 for i in range(26)]
for i in range(0, n):
	b[ord(a[i]) - 97] = b[ord(a[i]) - 97] + 1
for i in range(0, 26):
	if b[i] != 0 and n <= 26:
		d = d + b[i] - 1
if n > 26:
	print('-1')
else:
	print(d)


a = int(input())
b = input()
c = len(set(b))
print(a - c if a <= 26 else -1)


from __future__ import print_function

def solvecase():
	return ''

def solve():
	N = int(input())
	s = input().strip()
	l = len(s)
	if N > 26:
		return -1
	count = len(set((c for c in s)))
	return l - count

def main():
	ans = solve()
	print(ans)
main()


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
n = get_int()
string = get_string()
s = set()
count = 0
if len(string) > 26:
	print(-1)
else:
	for i in string:
		if i not in s:
			s.add(i)
		else:
			count += 1
	print(count)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	c = 0
	a = [0 for i in range(0, 26)]
	for i in range(0, n):
		if a[ord(s[i]) - ord('a')] == 0:
			a[ord(s[i]) - ord('a')] = 1
		else:
			c += 1
	print(c)


numb = int(input())
string = str(input())
unique = []
count = 0
for s in string:
	if not s in unique:
		unique.append(s)
	else:
		count += 1
if len(unique) + count > 26:
	print('-1')
else:
	print(count)


def main():
	n = int(input())
	s = input()
	if len(s) > 26:
		print(-1)
		return
	print(len(s) - len(set(s)))
main()


n = int(input())
x = str(input())
if len(x) > 26:
	print(-1)
else:
	s = []
	i = 0
	while i < len(x):
		s.append(x[i])
		i += 1
	d = {x: s.count(x) for x in s}
	x = len(d)
	y = len(s)
	print(y - x)


from sys import stdin, stdout
n = int(stdin.readline())
s = list(stdin.readline().rstrip())
a = list(set(list('zxcvbnmlkjhgfdsaqwertyuiop')) - set(s))
st = set()
cnt = 0
for i in range(n):
	if s[i] not in st:
		st.add(s[i])
	elif a:
		cnt += 1
		a.pop()
	else:
		cnt = -1
		break
stdout.write(str(cnt))


n = int(input())
s = str(input())
l = len(s)
if l > 26:
	print(-1)
else:
	a = []
	for i in s:
		a.append(i)
	u = len(set(a))
	print(l - u)


n = int(input())
data = sorted(input())
cnt = 0
for i in range(1, n):
	if data[i] == data[i - 1]:
		cnt += 1
if n > 26:
	print(-1)
else:
	print(cnt)


from collections import Counter
n = int(input())
s = str(input())
if len(s) == 1:
	print(0)
	exit()
count = Counter(s)
c = 0
for value in count.values():
	if value >= 2:
		c = c + (value - 1)
d = 26 - (n - c)
if c > d:
	print(-1)
else:
	print(c)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	alp = 'abcdefghijklmnopqrstuvwxyz'
	ans = 0
	for elem in alp:
		ans += max(0, s.count(elem) - 1)
	print(ans)


n = int(input())
s = str(input())
a = n - len(list(set(s)))
if len(s) > 26:
	print(-1)
else:
	print(a)


input()
s = input()
l = len(s)
if l > 26:
	print(-1)
else:
	d = dict()
	for i in range(l):
		if s[i] not in d:
			d[s[i]] = 1
		else:
			d[s[i]] += 1
	count = 0
	for j in d:
		if d[j] > 1:
			count += d[j] - 1
	print(count)


import string
n = int(input())
s = input()
used_letters = {}
free_letters = []
for c in s:
	used_letters[c] = True
for c in string.ascii_lowercase:
	if c not in used_letters:
		free_letters.append(c)
used_letters = {}
res = 0
for c in s:
	if c not in used_letters:
		used_letters[c] = True
	elif len(free_letters) > 0:
		free_letter = free_letters.pop()
		used_letters[free_letter] = True
		res += 1
	else:
		res = -1
		break
print(res)


n = int(input())
s = input()
if n > 26:
	print(-1)
	exit()
cnt = [0] * 26
for i in s:
	cnt[ord(i) - ord('a')] += 1
res = 0
for i in cnt:
	res += max(0, i - 1)
print(res)


from sys import stdin
trim = lambda s: s[:-1] if s[-1] == '\n' else s
n = int(stdin.readline())
s = trim(stdin.readline())
if n >= 27:
	print(-1)
else:
	print(n - len(set(s)))


import sys, threading, os.path
import string
import collections, heapq, math, bisect
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)

def main():
	if os.path.exists('in.txt'):
		input = open('in.txt', 'r')
	else:
		input = sys.stdin
	n = int(input.readline())
	st = str(input.readline().rstrip('\n'))
	dict = {}
	for x in st:
		if x in dict:
			dict[x] += 1
		else:
			dict[x] = 1
	num_of_lett = 0
	num_of_changes = 0
	for x in dict:
		num_of_lett += dict[x]
		if dict[x] > 1:
			num_of_changes += dict[x] - 1
	if n > 26 or num_of_lett > 26:
		output = -1
	else:
		output = num_of_changes
	if os.path.exists('out.txt'):
		open('out.txt', 'w').writelines(str(output))
	else:
		sys.stdout.write(str(output))
main()


import string
(x, y) = (input(), input())
t = string.ascii_lowercase
tp = 0
if len(y) > 26:
	print('-1')
else:
	for i in t:
		if i in y:
			tp = tp + 1
	print(len(y) - tp)


n = input()
string = input()
element = []
if int(n) > 26:
	print(-1)
else:
	for i in string:
		element.append(i)
	a = element[:]
	element = set(element)
	b = len(a) - len(element)
	print(b)


n = int(input())
str1 = input()
str2 = len(set(str1))
if n > 26:
	print(-1)
else:
	print(n - str2)


string_length = int(input())
string = input()
if len(string) > 26:
	print('-1')
else:
	count_char_to_change = 0
	unique_chars = list(set(string))
	for char in unique_chars:
		count_char_to_change += string.count(char) - 1
	print(count_char_to_change)


import string
N = int(input())
S = input()
se = set([])
for s in S:
	se.add(s)
ans = N - len(se)
if ans > len(string.ascii_lowercase) - len(se):
	ans = -1
print(ans)


n = int(input())
f = input()
r = ''.join(set(f))
if n > 26:
	print(-1)
else:
	print(len(f) - len(r))


import sys

def main():
	n = int(sys.stdin.readline())
	mystr = sys.stdin.readline().rstrip()
	if n > 26:
		print(-1)
	else:
		S = set(list(mystr))
		print(len(mystr) - len(S))
main()


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	q = set()
	for i in s:
		q.add(i)
	print(n - len(q))


n = int(input())
str1 = input()
chars = list(str1)
if n > 26:
	print(-1)
else:
	dict1 = {}
	for i in chars:
		if dict1.get(i, 0) == 0:
			dict1[i] = 1
		else:
			dict1[i] += 1
	ans = 0
	for i in dict1.values():
		ans += i - 1
	print(ans)


a = int(input())
b = input()
if a - len(set(b)) <= 26 and 26 - len(set(b)) >= a - len(set(b)):
	print(a - len(set(b)))
else:
	print(-1)


n = int(input())
word = input()
if n > 26:
	print(-1)
else:
	arr = []
	counter = 0
	for i in range(n):
		if word[i] in arr:
			counter += 1
		else:
			arr.append(word[i])
	print(counter)


def solve(s):
	letters = []
	k = 0
	for x in s:
		if x in letters:
			k += 1
		else:
			letters.append(x)
	if k > 26 - len(letters):
		return -1
	else:
		return k
n = int(input())
s = input()
print(solve(s))


import sys
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
n = int(input())
string = input().strip()
ans = 0
if n > 26:
	print(-1)
else:
	x = set(list(string))
	print(n - len(x))


n = input()
n = int(n.strip())
niz = input()
niz = niz.strip()
razl = set()
ponovitev = 0
for znak in niz:
	if znak in razl:
		ponovitev += 1
	else:
		razl.add(znak)
if 26 - len(razl) >= ponovitev:
	print(ponovitev)
else:
	print(-1)


n = int(input())
str = input()
print(len(str) - len(set(str)) if n < 27 else -1)


n = int(input())
s = input()
l1 = []
count = 0
for c in s:
	if c in l1:
		count += 1
	else:
		l1.append(c)
if count + len(l1) > 26:
	print('-1')
else:
	print(count)


from collections import defaultdict
import math
n = int(input())
a = input()
if n > 26:
	print('-1')
else:
	c = defaultdict(lambda : 0)
	for i in a:
		c[i] += 1
	print(n - len(c.keys()))


def check(s1):
	if len(s1) == len(set(s1)):
		return False
	else:
		return True
n = int(input())
s = input()
s1 = list(s)
res = []
c = 0
if n > 26:
	print(-1)
elif check(s1) == True:
	for i in s1:
		if i not in res:
			res.append(i)
		else:
			c += 1
	print(c)
else:
	print(0)


n = int(input())
str = input()
a = []
for v in str:
	if v not in a:
		a.append(v)
print(n - len(a) if n < 27 else -1)


l = int(input())
s = input()
l_s = len(set(s))
if l > 26:
	print(-1)
else:
	print(l - l_s)


from collections import defaultdict

def main():
	cntr = defaultdict(int)
	n = int(input())
	if n > ord('z') - ord('a') + 1:
		print(-1)
		return
	s = input()
	for c in s:
		cntr[c] += 1
	ans = 0
	for e in cntr.values():
		ans += e - 1
	print(ans)
main()


n = int(input())
s = input()
mp = {}
ans = 0
for i in range(n):
	if s[i] not in mp:
		mp[s[i]] = 1
	else:
		ans += 1
		mp[s[i]] += 1
if ans <= 26 - len(mp):
	print(ans)
else:
	print(-1)


N = int(input())
S = input()
Set = set(S)
if N > 26:
	print(-1)
else:
	print(N - len(Set))


a = int(input())
s = list(input())
if a > 26:
	print(-1)
else:
	b = set()
	for i in s:
		b.add(i)
	print(a - len(b))


n = int(input())
input_string = input()
map = {}
for i in range(0, len(input_string)):
	if input_string[i] in map:
		map[input_string[i]] += 1
	else:
		map[input_string[i]] = 1
sum = 0
for value in map.values():
	sum = sum + value
if sum > 26:
	print(-1)
else:
	res = 0
	for value in map.values():
		res = res + value - 1
	print(res)


n = int(input())
S = input()
if n > 26:
	ans = -1
else:
	sSet = set(S)
	ans = n - len(sSet)
print(ans)


t = int(input())
a = input()
f = list(set(a))
if len(a) < 27:
	print(len(a) - len(f))
else:
	print(-1)


def solvecase():
	return ''

def solve():
	N = int(input())
	s = input().strip()
	l = len(s)
	if N > 26:
		return -1
	count = len(set((c for c in s)))
	return l - count

def main():
	ans = solve()
	print(ans)
main()


input()
n = input()
print(len(n) - len(set(n)) if len(n) < 27 else -1)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	l = 0
	p = set()
	for i in range(n):
		if not s[i] in p:
			p.add(s[i])
		else:
			l += 1
	print(l)


n = int(input())
string = input()
t = []
k = 0
if n > 26:
	print(-1)
else:
	for i in range(n):
		if string[i] in t:
			k = k + 1
		else:
			t.append(string[i])
	print(k)


n = int(input())
if n > 26:
	print('-1')
	exit(0)
str = input()
a = [0] * 26
for x in str:
	y = ord(x) - ord('a')
	a[y] += 1
ans = 0
for x in a:
	ans += max(0, x - 1)
print(ans)


n = int(input())
a = input()
k = len({*a})
print([n - k, -1][n > 26])


n = int(input())
s = input()
st = set()
for i in range(len(s)):
	st.add(s[i])
k = n - len(st)
if k + len(st) <= 26:
	print(k, end='')
else:
	print('-1', end='')


n = int(input())
s = input()
dic = {}
for i in s:
	if i not in dic:
		dic[i] = 1
	else:
		dic[i] += 1
count = 0
for i in dic:
	count += dic[i] - 1
alpha = 26 - len(dic)
if count <= alpha:
	print(count)
else:
	print(-1)


n = int(input())
if n > 26:
	print(-1)
	exit()
s = input()
t = []
for i in range(26):
	t.append(0)
for l in s:
	t[ord(l) - ord('a')] += 1
sum = 0
for l in t:
	if l > 1:
		sum += l - 1
print(sum)


import math
alph = 'abcdefghijklmnopqrstuvwxyz'
n = int(input())
s = str(input())
d = [0] * 26
E = 0
if n > 26:
	print(-1)
else:
	for i in s:
		d[alph.index(i)] += 1
	for i in range(26):
		E += max(0, d[i] - 1)
	print(E)


p = int(input())
s = input()
z = set(s)
if p > 26:
	print('-1')
else:
	print(p - len(z))


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	count = dict()
	result = 0
	for c in s:
		if c not in count.keys():
			count.update({c: 1})
		else:
			count[c] += 1
	for key in count.keys():
		result += count[key] - 1
	print(result)


a = int(input())
if a > 26:
	print(-1)
else:
	print(a - len(set(input())))


(n, l) = (int(input()), len(set(input())))
print([n - l, -1][n > 26])


_ = input()
s = input()
unique = len(set(s))
if len(s) > 26:
	print(-1)
else:
	print(len(s) - unique)


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	print(n - len(set((c for c in s))))


from collections import Counter
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	sum = 0
	counter = Counter(s)
	for i in counter:
		sum += counter[i] - 1
	print(sum)


dic = {}
l = int(input())
s = str(input())
if l > 26:
	print(-1)
else:
	ret = 0
	for char in s:
		if char in dic:
			ret += 1
		else:
			dic[char] = True
	print(ret)


n = int(input())
a = input().lower()
d = dict()
for x in a:
	d[x] = 0
print(n - len(d) if n - len(d) >= 0 and n <= 26 else -1)


n = int(input())
s = input()
s2 = set(s)
if n > 26:
	print('-1')
else:
	print(len(s) - len(s2))


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	d = {}
	for c in s:
		if c not in d:
			d[c] = 0
		d[c] += 1
	sol = 0
	for c in d:
		sol += max(0, d[c] - 1)
	print(sol)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	appear = {}
	for x in range(n):
		if s[x - 1] not in appear:
			appear[s[x - 1]] = 1
		else:
			appear[s[x - 1]] += 1
	tot = 0
	for x in appear:
		if appear[x] > 1:
			tot += appear[x] - 1
	print(tot)


n = int(input())
s = input()
a = []
cnt = 0
if n > 26:
	print('-1')
else:
	for i in s:
		if i in a:
			cnt += 1
		else:
			a.append(i)
	print(cnt)


x = int(input())
str1 = input()
if x > 26:
	print(-1)
else:
	li = set(list(str1))
	print(x - len(li))


n = int(input())
s = input()
count = [0] * 26
for x in s:
	count[ord(x) - ord('a')] += 1
ans = 0
ava = 0
for x in count:
	if x > 0:
		ava += 1
		ans += x - 1
if 26 - ava < ans:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	d = dict()
	for x in s:
		if x in d:
			d[x] += 1
		else:
			d[x] = 1
	p = 0
	for y in d:
		p += d[y] - 1
	print(p)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	n = I()
	s = S()
	if n > 26:
		return -1
	c = collections.Counter(s)
	return n - len(c)
print(main())


input()
w = str(input().strip())
table = [False] * 26
change = 0
for c in w:
	l = ord(c) - ord('a')
	if not table[l]:
		table[l] = True
	else:
		change += 1
print(-1) if change + sum(table) > 26 else print(change)


import bisect
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
n = I()
s = input()
d = Counter(s)
if n <= 26:
	print(n - len(d))
else:
	print(-1)


n = int(input())
word = input()
newWord = ''
LETTERS = 'abcdefghijklmnopqrstuvwxyz'
usedChars = {}
moves = 0
if n > 26:
	print('-1')
else:
	for c in word:
		if c not in usedChars:
			usedChars[c] = 0
	for c in word:
		if usedChars[c] > 0:
			for l in LETTERS:
				if l not in usedChars:
					usedChars[l] = 0
					newWord = newWord + str(l)
					moves = moves + 1
					break
		else:
			usedChars[c] += 1
	print(moves)


n = int(input())
s = str(input())
count = 0
used = []
if n > 26:
	print(-1)
else:
	for i in s:
		if i not in used:
			count += s.count(i) - 1
			used.append(i)
	print(count)


input()
a = input()
print([len(a) - len(set(a)), -1][len(a) > 26])


n = int(input())
array = input()
result = n - len(set(array))
if n > 26:
	print(-1)
else:
	print(result)


n = int(input())
s = input()
hmmmm = []
cnt = 0
for i in range(n):
	if s[i] in hmmmm:
		cnt += 1
	else:
		hmmmm.append(s[i])
if len(hmmmm) + cnt > 26:
	print(-1)
else:
	print(cnt)


import sys
n = int(input())
if n > 26:
	print(-1)
	return
s = input()
f = set()
ctr = 0
for i in s:
	if i in f:
		ctr += 1
	else:
		f.add(i)
print(ctr)


n = int(input())
word = list(input())
if n > 26:
	print(-1)
	exit(0)
print(n - len(set(word)))


def main():
	num = input()
	val = input()
	if len(val) > 26:
		print(-1)
		return
	ans = 0
	freq = {}
	for i in range(len(val)):
		if val[i] in freq:
			ans = ans + 1
		else:
			freq[val[i]] = 1
	print(ans)
main()


n = int(input())
s = str(input())
if n > 26:
	print(-1)
else:
	A = [0] * 26
	res = 0
	for i in s:
		A[ord(i) - ord('a')] += 1
	for i in range(26):
		if A[i] > 1:
			res += A[i] - 1
	print(res)


n = int(input())
l = list(input())
if len(l) == len(set(l)):
	print(0)
	exit()
if n > 26:
	print(-1)
	exit()
y = list(set(l))
x = []
ans = 0
for i in range(len(y)):
	x.append(l.count(y[i]))
for i in range(len(x)):
	ans += x[i] - 1
print(ans)


no = int(input())
ls = input()
if no > 26:
	print('-1')
	exit()
st = set(ls)
n = len(ls) - len(set(ls))
print(n)


from sys import stdin
n = int(input())
str = stdin.readline()
alphabet = 'abcdefghijklmnopqrstuvwxyz'
count = [0] * 26
res = 0
if n > 26:
	print('-1')
else:
	for ch in range(n):
		for i in range(26):
			if str[ch] == alphabet[i]:
				if count[i] == 0:
					count[i] = 1
				else:
					res += 1
	print(res)


n = int(input())
l = list(input())
if n > 26:
	print(-1)
	exit()
print(n - len(set(l)))


def main():
	n = int(input())
	s = input()
	if n > 26:
		print(-1)
	else:
		n_chars = len(list(dict.fromkeys([c for c in s])))
		print(n - n_chars)
main()


def next_letter(l):
	if l == 'z':
		return 'a'
	return chr(ord(l) + 1)
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	print(n - len(set(list(s))))


from collections import Counter

def get_ans():
	n = int(input())
	s = input()
	if n > 26:
		return -1
	c = Counter(s)
	ans = 0
	for (k, v) in c.items():
		if v > 1:
			ans += v - 1
	return ans
ans = get_ans()
print(ans)


n = int(input())
s = input()
if n > 26:
	print(-1)
	exit()
c = [0] * 26
for si in s:
	c[ord(si) - 97] += 1
k = 0
for i in range(26):
	if c[i] >= 2:
		k = k + (c[i] - 1)
print(k)


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	r = ord('a')
	l = [0] * 26
	for i in range(n):
		l[ord(s[i]) - r] += 1
	p = 0
	q = 0
	for i in range(26):
		if l[i] == 0:
			p += 1
		else:
			q += l[i] - 1
	if q > p:
		print(-1)
	else:
		print(q)


from collections import Counter
input()
s = input()
c = Counter(s)
res = sum([x - 1 for (_, x) in c.items()])
if res + len(c) > 26:
	print(-1)
	exit()
else:
	print(res)


def process(mystr):
	setstr = list(set(mystr))
	change = 0
	for i in range(len(setstr)):
		change += mystr.count(setstr[i]) - 1
		if change > 25 - i:
			return -1
	return change
n = int(input())
mystr = input().lower()
print(process(mystr))


n = int(input())
l = list(input())
r = list(set(l))
p = len(r)
u = len(l)
c = 0
q1 = 'abcdefghijklmnopqrstuvwxyz'
for i in range(u - p):
	for j in range(26):
		if q1[j] not in r:
			r.append(q1[j])
			c += 1
			break
if c >= 0 and len(r) == u:
	print(c)
else:
	print(-1)


def main():
	n = int(input())
	print(n - len(set(input())) if n < 27 else -1)

def __starting_point():
	main()
__starting_point()


n = int(input())
a = input()
count = 0
letters = [0] * 26
if len(a) > 26:
	print(-1)
else:

	def findPos(x):
		return ord(x) - ord('a')
	for i in a:
		letters[findPos(i)] += 1
	for i in range(26):
		if letters[i] != 0:
			count += 1
	print(n - count)


n = int(input())
s = input()
c = set()
for i in range(n):
	c.add(s[i])
foo = n - len(c)
if foo <= 26 - len(c):
	print(foo)
else:
	print(-1)


from collections import Counter
n = int(input())
s = input()

def dv(s):
	if len(s) > 26:
		return '-1'
	c = Counter(s)
	t = 0
	for i in c:
		t += c[i] - 1
	return t
print(dv(s))


from collections import Counter
x = input()
s = input()
if len(s) > 26:
	print(-1)
else:
	c = Counter(s)
	tot = 0
	for (k, v) in c.items():
		tot += v - 1
	print(tot)


def different_is_good(mystr):
	if len(mystr) > 26:
		print(-1)
		return
	(hash_, diff) = ([0] * 128, 0)
	for char in mystr:
		if hash_[ord(char)] == 1:
			diff += 1
		else:
			hash_[ord(char)] = 1
	print(diff)
_ = int(input())
different_is_good(str(input()))


n = int(input())
a = set([i for i in input()])
if n > 26:
	print(-1)
else:
	print(n - len(a))


n = int(input())
s = input()
if n > 26:
	print(-1)
	exit(0)
k = set()
for i in s:
	k.add(i)
print(n - len(k))


n = int(input())
s = str(input())

def main(n, s):
	if n > 26:
		print(-1)
		return
	l = []
	for i in s:
		l.append(i)
	print(len(l) - len(set(l)))
main(n, s)


n = int(input())
st = input()
ans = len(st) - len(set(st))
if ans <= 26 - len(set(st)):
	print(ans)
else:
	print(-1)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	ans = 0
	d = {}
	alpha = 'qwertyuiopasdfghjklzxcvbnm'
	for i in range(26):
		d[alpha[i]] = 0
	for i in range(n):
		d[s[i]] += 1
		if d[s[i]] > 1:
			ans += 1
	print(ans)


x = int(input())
y = input()
z = set(y)
if x > 26:
	print(-1)
else:
	print(len(y) - len(z))


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	k = 0
	c = set('abcdefghijklmnopqrstuvwxyz').difference(set(s))
	c = list(c)
	for i in range(len(s)):
		if s.count(s[i]) > 1:
			s = s[:i] + c.pop(0) + s[i + 1:]
			k += 1
	print(k)


n = int(input())
s = input()
cnt = 0
if n < 27:
	for i in range(0, n):
		c = s[0]
		s = s[1:]
		if c in s:
			cnt += 1
else:
	cnt = -1
print(cnt)


n = int(input())
t = list(input())
m = list(set(t))
a = len(t) - len(m)
if a > 26 - len(m):
	print('-1')
else:
	print(a)


n = int(input())
S = set(list(input()))
if n > 26:
	print(-1)
else:
	print(n - len(S))


n = int(input())
if n > 26:
	print(-1)
else:
	s = list(input())
	t = set(s)
	print(len(s) - len(t))


n = int(input())
s = str(input())
if n > 26:
	print(-1)
else:
	count = 0
	l = []
	for c in s:
		if not c in l:
			l.append(c)
			count = count + 1
	print(n - count)


input()
t = input()
print(-1 if len(t) > 26 else len(t) - len(set(t)))


n = int(input())
s = list(input())
w = set()
for i in range(n):
	w.add(s[i])
if n > 26:
	print(-1)
else:
	print(len(s) - len(w))


n = int(input())
s = input()
l = []
for _ in range(26):
	l.append(0)
for i in s:
	l[ord(i) - 97] += 1
c = l.count(0)
k = 0
f = 0
for i in range(26):
	if l[i] > 1:
		if c - k >= l[i] - 1:
			k += l[i] - 1
		else:
			f = 1
			break
if f == 1:
	print(-1)
else:
	print(k)


s = input()
s = input()
ele = []
ans = 0
if len(s) > 26:
	print(-1)
else:
	for i in s:
		if i in ele:
			ans += 1
		else:
			ele.append(i)
	print(ans)


def main():
	n = eval(input(''))
	s = input('')
	count = 0
	ncount = 0
	for i in range(97, 123):
		ch = chr(i)
		co = s.count(ch)
		if co > 1:
			count = count + (co - 1)
		if co >= 1:
			ncount = ncount + 1
	ans = count
	r = 26 - ncount
	if r >= ans:
		print(ans)
	else:
		print('-1')
main()


n = int(input())
b = input()
distinctLetters = []
if len(b) > 26:
	print(-1)
else:

	def findIndex(x, i):
		for j in x:
			if j == i:
				return True
		return False
	for i in b:
		if findIndex(distinctLetters, i) == False:
			distinctLetters.append(i)
	print(n - len(distinctLetters))


n = int(input())
if n > 26:
	print(-1)
	exit()
r = 0
s = input().strip()
A = set()
for i in range(n):
	c = s[i]
	if c in s[:i] or c in s[i + 1:]:
		if c not in A:
			A = A.union(c)
		r += 1
print(r - len(A))


z = int(input())
l = len(set(input()))
print(['-1', '%d' % (z - l)][26 - l - (z - l) > -1])


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	d = {}
	cnt = 0
	for i in s:
		if i in d:
			d[i] += 1
			cnt += 1
		else:
			d[i] = 1
	print(cnt)


n = int(input())
s = str(input())
a = set(s)
m = len(a)
ans = 0
for i in a:
	if s.count(i) > 1:
		ans += s.count(i) - 1
if ans + m > 26:
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
d = dict()
for letter in s:
	d[letter] = d.get(letter, -1) + 1
l = len(d)
k = 0
dv = d.values()
for i in dv:
	k += i
if k + l > 26:
	print(-1)
else:
	print(k)


n = int(input())
s = str(input())
ans = -1
if n <= 26:
	ans = n - len(set(s))
print(ans)


n = int(input())
l = input()
p = set(l)
sum = 0
not_equal = 0
equal = 0
if n > 26:
	print(-1)
elif len(p) == len(l):
	print(0)
else:
	d = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
	for num in p:
		d[num] = l.count(num)
		sum += l.count(num)
		equal += 1
	for n in d:
		if d[n] == 0:
			not_equal += 1
	if not_equal - sum < 26:
		print(sum - equal)
	else:
		print(-1)


def remove(h, x):
	temp = []
	for k in range(len(h)):
		if h[k] != x:
			temp.append(h[k])
	return temp

def process(temp):
	tempo = temp[:]
	a = temp.count(temp[0]) - 1
	answer = temp[0]
	temp = remove(temp, temp[0])
	while len(temp) > 0:
		t = temp.count(temp[0]) - 1
		a += t
		answer = temp[0]
		temp = remove(temp, temp[0])
	return a
n = int(input())
x = input()
a = []
if n >= 27:
	print('-1')
else:
	a = []
	for i in range(n):
		a.append(x[i])
	temp = process(a)
	print(temp)


from sys import exit
n = int(input())
if n > 26:
	print(-1)
	exit()
s = input()
a = [0 for _ in range(26)]
for c in s:
	a[ord(c) - ord('a')] += 1
ans = 0
for i in range(26):
	ans += max(0, a[i] - 1)
print(ans)


n = int(input())
arr = input()
if len(arr) > 26:
	print(-1)
	exit(0)
d = set()
res = 0
for a in arr:
	if a in d:
		res += 1
	else:
		d.add(a)
print(res)


from sys import stdin
N = int(stdin.readline())
S = stdin.readline().strip()
print(-1 if N > 26 else N - len(set(S)))


def diff_subs(inp):
	if len(inp) > 26:
		return -1
	return len(inp) - len(set(inp))
useless = input()
print(diff_subs(input().strip()))


from collections import defaultdict
n = int(input())
if n > 26:
	print('-1')
else:
	s = input().strip()
	count = defaultdict(int)
	ans = 0
	for c in s:
		if count[c] >= 1:
			ans += 1
		else:
			count[c] += 1
	print(ans)


n = int(input())
s = str(input())
s = s.lower()
tmp = 0
ls = []
for i in s:
	if i not in ls:
		tmp += 1
		ls.append(i)
if n > 26:
	print(-1)
else:
	print(n - tmp)


n = int(input())
s = input()
repr = {}
t = 0
if n > 26:
	print(-1)
else:
	for i in s:
		if i in repr:
			repr[i] += 1
		else:
			repr[i] = 1
			t += 1
	print(n - t)


input()
s = input()
print(-1 if len(s) > 26 else len(s) - len(set(s)))


import os
import sys
n = int(input())
s = str(input())
alpha = [0] * 27
c = set()
for i in range(len(s)):
	alpha[ord(s[i]) - 96] += 1
	c.add(s[i])
if len(c) == 26 and len(s) > 26:
	print('-1')
elif len(c) == 26 and len(s) == 26:
	print('0')
elif len(c) <= 26 and len(s) <= 26:
	ans = 0
	for j in range(1, 27):
		if alpha[j] != 0:
			ans += alpha[j] - 1
	print(ans)
else:
	print('-1')


n = int(input())
s = input()
s1 = list(s)
p = len(list(set(s)))
if n > 26:
	print(-1)
else:
	print(n - p)


n = int(input())
s = input()
count = 0
lst = [0] * 26
for ch in s:
	lst[ord(ch) - ord('a')] += 1
for i in range(len(lst)):
	if lst[i] > 1:
		count = count + lst[i] - 1
if n > 26:
	print(-1)
else:
	print(count)


def solve():
	n = int(input())
	mystr = input()
	count = 0
	if len(mystr) > 26:
		print(-1)
		return
	for i in range(len(mystr)):
		if mystr[i] in mystr[:i]:
			continue
		if mystr[i] in mystr[i + 1:]:
			count += mystr[i + 1:].count(mystr[i])
	print(count)
solve()


import sys
n = eval(input())
s = list(map(str, input()))
z = list()
ct = 0
for element in s:
	if element not in z:
		z.append(element)
		ct = ct + s.count(element)
if n > 26:
	print(-1)
	sys.exit()
print(n - len(z))


n = int(input())
st = input()
answer = 0
done = False
if len(st) > 26:
	done = True
else:
	d = {}
	for ch in st:
		d[ch] = d.get(ch, 0) + 1
if not done:
	for key in d:
		answer += d[key] - 1
else:
	answer = -1
print(answer)


n = int(input())
s = input()
if n > 26:
	print(-1)
	exit
else:
	unique_ch = []
	for ch in s:
		if ch not in unique_ch:
			unique_ch.append(ch)
	print(len(s) - len(unique_ch))


n = int(input())
f = [0] * 26
s = input()
if len(s) > 26:
	print(-1)
else:
	for i in range(len(s)):
		f[ord(s[i]) - ord('a')] += 1
	ans = 0
	for i in range(26):
		if f[i] > 1:
			ans += f[i] - 1
	print(ans)


import sys
from collections import Counter
from math import factorial
input = sys.stdin
output = sys.stdout
combinations_dynamic = dict()

def combinations(n, k):
	if k > n - k:
		k = n - k
	if k < 0:
		return 0
	if n < 1:
		return 0
	if k == 0:
		return 1
	if k == 1:
		return n
	question = tuple((n, k))
	if question not in combinations_dynamic:
		combinations_dynamic[question] = combinations(n - 1, k - 1) + combinations(n - 1, k)
	return combinations_dynamic[question]

def read_int():
	return [int(x) for x in input.readline().rstrip().split()]
[n] = read_int()
line = input.readline().rstrip()
answer = -1
if len(line) <= 26:
	chars = set()
	for c in line:
		chars.add(c)
	answer = len(line) - len(chars)
output.write('%d\n' % answer)


n = int(input())
s = str(input())
if n > 26:
	print('-1')
	exit(0)
used = [0] * 26
for x in s:
	used[ord(x) - ord('a')] += 1
cnt = 0
for i in range(26):
	if used[i] > 0:
		cnt += 1
res = n - cnt
print(res)


alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
n = int(input())
string = input()
answer = 0
if n > 26:
	print(-1)
else:
	for letter in alphabet:
		if letter in string:
			answer += string.count(letter) - 1
	print(answer)


n = int(input())
string = str(input())
count = [0] * 26
cnt = 0
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for i in range(n):
	count[alphabet.find(string[i])] += 1
for i in count:
	if i > 1:
		cnt += i - 1
if n > 26:
	print('-1')
else:
	print(cnt)


import sys
f = sys.stdin
n = int(f.readline())
s = str(f.readline())
if n > 26:
	print(-1)
else:
	v = n - len(set(s)) + 1
	print(v)


def substrings_checker(n, s):
	if n > 26:
		return -1
	elif len(set(s)) == len(s):
		return 0
	else:
		change = 0
		store = []
		for x in s:
			if x in store:
				change += 1
			else:
				store.append(x)
		return change
n = int(input())
s = input()
print(substrings_checker(n, s))


import sys
num = int(input())
if num > 26:
	print('-1')
else:
	line = input()
	line_set = {x for x in line}
	print(num - len(line_set))


arr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
n = int(input())
s = input()
count = 0
for i in range(n):
	if s[i] in s[:i] or s[i] in s[i + 1:]:
		flag = False
		for j in arr:
			if not j in s:
				s = s[:i] + j + s[i + 1:]
				flag = True
		if not flag:
			print(-1)
			exit()
		else:
			count += 1
print(count)


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	print(n - len(set(s)))


n = int(input())
s = input()
ans = 0
ss = set(s)
for x in ss:
	ans += s.count(x) - 1
print(-1 if ans + len(ss) > 26 else ans)


n = int(input())
s = input()
count = 0
c = []
if n > 26:
	print(-1)
else:
	for i in s:
		if i in c:
			count += 1
		else:
			c.append(i)
	print(count)


n = int(input())
s = input()
ans = 0
cnt = 0
for i in range(ord('a'), ord('z') + 1):
	x = s.count(chr(i))
	if x > 0:
		cnt += 1
		ans += x - 1
if ans > 26 - cnt:
	print(-1)
else:
	print(ans)


input()
s = input()
ans = 0
if len(s) > 26:
	print(-1)
	quit()
for let in 'abcdefghijklmnopqrstuvwxyz':
	ans += max(0, s.count(let) - 1)
print(ans)


n = int(input())
s = input()
if n > ord('z') - ord('a') + 1:
	print(-1)
else:
	print(n - len(set(s)))


n = int(input())
print([n - len(set(list(input()))), -1][n > 26])


n = int(input())
str = input()
a = []
if n > 26:
	print(-1)
else:
	for i in range(n):
		if str[i] not in a:
			a.append(str[i])
	print(n - len(a))


n = int(input())
s = list(input())
p = list(set(s))
if len(s) > 26:
	print('-1')
elif len(s) == 26 and len(p) == 26:
	print('0')
else:
	for i in p:
		s.remove(i)
	print(len(s))


def get_answer(string):
	d = {}
	count = 0
	for s in string:
		if s not in d:
			count += 1
			d[s] = 1
		else:
			d[s] += 1
	need_to_change = 0
	for k in d.keys():
		if d[k] > 1:
			need_to_change += d[k] - 1
	if 26 - count < need_to_change:
		print(-1)
	else:
		print(need_to_change)
input()
string = input()
get_answer(string)


from collections import Counter
x = int(input())
st = input()
ko = len(st)
f = len(set(st))
if ko > 26:
	print(-1)
else:
	print(ko - f)


n = int(input())
st = input()
st1 = set(st)
if n < 27:
	print(n - len(st1))
else:
	print(-1)


alpha = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']
a = int(input())
b = input()
totals = [0] * 26
for i in range(26):
	totals[i] += b.count(alpha[i])
c = sum(totals) - (26 - totals.count(0))
if c > totals.count(0):
	print(-1)
else:
	print(c)


n = int(input())
z = input()
y = set(z)
r = len(y)
if len(z) == len(y):
	print(0)
else:
	i = len(z) - len(y)
	l = [0] * (26 - r)
	while True:
		if i != 0 and l == []:
			print(-1)
			break
		i -= 1
		l.remove(0)
		if i == 0:
			print(len(z) - len(y))
			break


ln = input()
ln = input()
if len(ln) > 26:
	print(-1)
else:
	print(len(ln) - len(set(ln)))


m = int(input())
raw_str = input()

def count_char(arr):
	temp_array = [0] * 128
	for i in range(len(arr)):
		indx = ord(arr[i])
		temp_array[indx] += 1
	return temp_array[97:123]
count_arr = count_char(raw_str)
if m > 26:
	count = -1
else:
	count = 0
	for ele in count_arr:
		if ele > 1:
			count += ele - 1
print(count)


import sys
input = sys.stdin.readline

def prog():
	n = int(input())
	s = input().strip()
	if len(s) > 26:
		print(-1)
	else:
		a = set(s)
		print(len(s) - len(a))
prog()


n = int(input())
if n > 26:
	print(-1)
else:
	s = str(input())
	w = set(s)
	l = len(w)
	print(n - l)


import string
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	ans = sum((max(s.count(x) - 1, 0) for x in string.ascii_lowercase))
	print(ans)


import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())

def main():
	n = inp()
	a = input()
	count = defaultdict(lambda : 0)
	for i in a:
		count[i] += 1
	res = 0
	tot = 0
	for k in count:
		tot += count[k]
		res += count[k] - 1
	if n > 26:
		print(-1)
	else:
		print(res)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


(n, k) = (int(input()), len(set(list(input()))))
print([-1, n - k][n < 27])


(n, s) = (int(input()), input())
if n > 26:
	print(-1)
	exit()
cnt = [0] * 26
for v in s:
	cnt[ord(v) - ord('a')] = 1
print(n - sum(cnt))


from sys import stdin, stdout
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import *
input = stdin.readline
prin = stdout.write
from random import sample
from collections import Counter, deque
from math import sqrt, ceil, log2, gcd
mod = 10 ** 9 + 7

class DisjSet:

	def __init__(self, n):
		self.rank = [1] * n
		self.parent = [i for i in range(n)]

	def find(self, x):
		if self.parent[x] != x:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, x, y):
		xset = self.find(x)
		yset = self.find(y)
		if xset == yset:
			return
		if self.rank[xset] < self.rank[yset]:
			self.parent[xset] = yset
		elif self.rank[xset] > self.rank[yset]:
			self.parent[yset] = xset
		else:
			self.parent[yset] = xset
			self.rank[xset] = self.rank[xset] + 1

def f(arr, i, j, d, dist):
	if i == j:
		return
	nn = max(arr[i:j])
	for tl in range(i, j):
		if arr[tl] == nn:
			dist[tl] = d
			f(arr, i, tl, d + 1, dist)
			f(arr, tl + 1, j, d + 1, dist)

def ps(n):
	cp = 0
	lk = 0
	arr = []
	countprev = 0
	while n % 2 == 0:
		n = n // 2
		lk += 1
	for ps in range(3, ceil(sqrt(n)) + 1, 2):
		lk = 0
		while n % ps == 0:
			n = n // ps
			lk += 1
	if n != 1:
		lk += 1
		return [lk, 'NO']
	return [lk, 'YES']

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def factorials(n, r):
	slr = n
	dpr = r
	qlr = 1
	qs = 1
	mod = 10 ** 9 + 7
	for ip in range(n - r + 1, n + 1):
		qlr = qlr * ip % mod
	for ij in range(1, r + 1):
		qs = qs * ij % mod
	ans = qlr * modInverse(qs) % mod
	return ans

def modInverse(b):
	qr = 10 ** 9 + 7
	return pow(b, qr - 2, qr)
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func

def power(arr):
	listrep = arr
	subsets = []
	for i in range(2 ** len(listrep)):
		subset = []
		for k in range(len(listrep)):
			if i & 1 << k:
				subset.append(listrep[k])
		subsets.append(subset)
	return subsets

def dis(xa, ya, xb, yb):
	return sqrt((xa - xb) ** 2 + (ya - yb) ** 2)

def ii():
	return int(input())

def ilist():
	return [int(x) for x in input().strip().split()]

def outstrlist(array: list) -> str:
	array = [str(x) for x in array]
	return ' '.join(array)

def islist():
	return list(map(str, input().split().rstrip()))

def outfast(arr: list) -> str:
	ss = ''
	for ip in arr:
		ss += str(ip) + ' '
	return prin(ss)
t = 1
for jj in range(t):
	n = ii()
	if n > 26:
		print(-1)
		continue
	s = input()
	print(len(s) - len(set(s)))


import unittest
import sys

class Good:

	def __init__(self, test_inputs=None):
		it = iter(test_inputs.split('\n')) if test_inputs else None

		def uinput():
			return next(it) if it else sys.stdin.readline().rstrip()
		[self.n] = map(int, uinput().split())
		self.s = list(uinput())

	def calculate(self):
		freq = [0] * 26
		for c in self.s:
			ltr = ord(c) - ord('a')
			freq[ltr] += 1
		zeroes = 0
		extra = 0
		for n in freq:
			if n == 0:
				zeroes += 1
			if n > 1:
				extra += n - 1
		result = -1 if extra > zeroes else extra
		return str(result)

class unitTests(unittest.TestCase):

	def test_single_test(self):
		test = '2\naa'
		d = Good(test)
		self.assertEqual(d.n, 2)
		self.assertEqual(d.s, ['a', 'a'])
		self.assertEqual(Good(test).calculate(), '1')
		test = '4\nkoko'
		self.assertEqual(Good(test).calculate(), '2')
		test = '5\nmurat'
		self.assertEqual(Good(test).calculate(), '0')
		test = '30\ndasdsadasdasdasdsadasdsadasdasda'
		self.assertEqual(Good(test).calculate(), '-1')

	def time_limit_test(self, nmax):
		import random
		import timeit
		test = str(nmax) + ' ' + str(nmax) + '\n'
		numnums = [str(i) + ' ' + str(i + 1) for i in range(nmax)]
		test += '\n'.join(numnums) + '\n'
		nums = [random.randint(1, 10000) for i in range(nmax)]
		test += ' '.join(map(str, nums)) + '\n'
		start = timeit.default_timer()
		d = Good(test)
		calc = timeit.default_timer()
		d.calculate()
		stop = timeit.default_timer()
		print('\nTimelimit Test: ' + '{0:.3f}s (init {1:.3f}s calc {2:.3f}s)'.format(stop - start, calc - start, stop - calc))
sys.setrecursionlimit(100000)
if sys.argv[-1] == '-ut':
	unittest.main(argv=[' '])
sys.stdout.write(Good().calculate())


n = int(input())
a = list(map(str, input().strip()))
print(n - len(set(a)) if n < 27 else -1)


n = int(input())
s = list(input())
set1 = set(s)
m = len(set1)
if n <= 26:
	print(n - m)
else:
	print('-1')


n = int(input())
s = input()
l = []
for i in range(n):
	if s[i] not in l:
		l.append(s[i])
if n - len(l) <= 26 - len(l):
	print(n - len(l))
else:
	print(-1)


n = int(input())
str = input()
if n > 26:
	print(-1)
	exit()
l = []
count = 0
for i in str:
	if i in l:
		count += 1
	else:
		l.append(i)
print(count)


i = int(input())
s = list(map(str, input()))
print(i - len(set(s)) if i <= 26 else -1)


n = int(input())
s = str(input())
d = {}
if n > 26:
	print(-1)
else:
	for i in s:
		if i not in d and s.count(i) > 1:
			d[i] = s.count(i)
	ans = 0
	for j in d:
		ans = ans + d[j] - 1
	print(ans)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	A = set()
	for i in range(n):
		A.add(s[i])
	print(n - len(A))


num = int(input())
arr = list(input())
if num > 26:
	print(-1)
else:
	print(num - len(set(arr)))


t = int(input())
p = input()
q = set(p)
if len(p) > 26:
	print(-1)
else:
	print(t - len(q))


n = int(input())
stri = input()
seta = set()
for c in stri:
	seta.add(c)
if n > 26:
	print(-1)
else:
	print(len(stri) - len(seta))


input()
chars = set()
input_word = input()
if len(input_word) > 26:
	print(-1)
else:
	for (i, c) in enumerate(input_word):
		chars.add(c)
	print(len(input_word) - len(chars))


n = int(input())
s = input()
lis = [0] * 26
ans = k = 0
for i in s:
	lis[ord(i) - ord('a')] += 1
for i in lis:
	if i > 1:
		ans += i - 1
	if i > 0:
		k += 1
if ans > 26 - k:
	print(-1)
else:
	print(ans)


n = int(input())
a = input()
if n > 26:
	print('-1')
else:
	a = list(a)
	a = set(a)
	l = len(a)
	print(n - l)


from sys import exit
from string import ascii_lowercase
n = int(input())
if n > 26:
	print(-1)
	exit()
s = input()
a = [sum((c == a for c in s)) for a in ascii_lowercase]
print(sum((max(0, x - 1) for x in a)))


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	se = set(s)
	print(len(s) - len(se))


from collections import Counter
n = int(input())
s = input()
c = Counter(s)
ans = 0
for x in c:
	if c[x] > 1:
		ans += c[x] - 1
print(-1 if n > 26 else ans)


while 1:
	try:
		n = int(input())
		s = input()
	except:
		break
	print(-1 if n > 26 else n - len(set(s)))


import sys
from collections import Counter
input = lambda : sys.stdin.readline()
int_arr = lambda : list(map(int, input().split()))
str_arr = lambda : list(map(str, input().split()))
get_str = lambda : map(str, input().split())
get_int = lambda : map(int, input().split())
get_flo = lambda : map(float, input().split())
mod = 1000000007

def solve(n, s):
	if n > 26:
		print('-1')
		return
	c = 0
	for (e, t) in Counter(s).items():
		if t > 1:
			c += t - 1
	print(c)
n = int(input())
s = str(input())
solve(n, s)


def main():
	n = int(input())
	s = list(input())
	if n > 26:
		print(-1)
	else:
		res = 0
		for e in set(s):
			res += s.count(e) - 1
		print(res)
main()


def task_2(s):
	n = len(s)
	if n > 26:
		return -1
	k = get_different_letters_count(s)
	return n - k

def get_different_letters_count(s):
	n = 0
	letters = []
	for l in s:
		if not l in letters:
			letters.append(l)
			n += 1
	return n
n = int(input())
s = input()
print(task_2(s))


n = int(input())
c = '\x00'
count = 0
a = input()
if n > 26:
	print('-1')
	exit(0)
for i in range(n):
	for j in range(i + 1, n):
		if a[i] == a[j]:
			count += int(1)
		c = a[j]
		if c == a[i]:
			break
print(count)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	ans = 0
	t = ''
	for c in s:
		if c not in t:
			ans += s.count(c) - 1
		t = t + c
	print(ans)


n = int(input())
arr = list(input())
if len(arr) > 26:
	print(-1)
else:
	print(len(arr) - len(set(arr)))


(n, s, m) = (input(), str(input()), {})
for c in s:
	m[c] = 1
print(-1 if len(s) > 26 else len(s) - len(m))


n = int(input())
s = input()
l = set(s)
count = 0
if len(s) > 26:
	print(-1)
else:
	for i in l:
		if s.count(i) > 1:
			count += s.count(i) - 1
	print(count)


k = []
for j in range(26):
	k.append(0)
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	changes = 0
	for i in s:
		if k[ord(i) - ord('a')] != 0:
			k[ord(i) - ord('a')] += 1
			changes += 1
		else:
			k[ord(i) - ord('a')] = 1
	print(changes)


from collections import defaultdict
num_chars = input()
in_str = input()
if len(in_str) > 26:
	print(-1)
else:
	frequencies = defaultdict(lambda : -1)
	for c in in_str:
		frequencies[c] += 1
	print(sum([frequencies[key] for key in frequencies.keys()]))


number = int(input())
string = input()
dicBuffer = {}
for i in range(0, number):
	if string[i] in dicBuffer:
		dicBuffer[string[i]] = dicBuffer[string[i]] + 1
	else:
		dicBuffer[string[i]] = 1
count = 0
for i in dicBuffer.keys():
	count += dicBuffer[i] - 1
if number > 26:
	count = -1
print(count)


n = int(input())
data = list(input())
data = set(data)
if n > 26:
	print(-1)
else:
	print(n - len(data))


n = int(input())
strg = input()
x = 0
if n > 26:
	print(str(-1))
else:
	while len(strg) > 0:
		c = strg[0]
		strg = strg[1:]
		if c in strg:
			x += 1
	print(x)


import sys
from bisect import bisect_left
from copy import deepcopy

def diff(first, second):
	second = set(second)
	return [item for item in first if item not in second]

def second():
	n = sys.stdin.readline()
	inp = sys.stdin.readline()
	mp = dict()
	res = 0
	if len(inp) <= ord('z') - ord('a') + 2:
		for i in inp:
			mp[i] = 0
		for i in inp:
			mp[i] += 1
		for i in mp:
			if mp[i] > 1:
				res += mp[i] - 1
		print(res)
	else:
		print(-1)
second()


n = int(input())
s = input()
a = []
ans = 0
for x in s:
	if x in a:
		ans += 1
	else:
		a.append(x)
	if ans > 26 - len(a):
		break
if ans > 26 - len(a):
	print(-1)
else:
	print(ans)


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	k = 0
	c = set(s)
	print(n - len(c))


n = int(input())
s = list(input())
f = set(s)
if n > 26:
	print('-1')
	exit(0)
else:
	print(n - len(f))


n = int(input())
s = input()
mydict = {}
for i in s:
	if i not in mydict:
		mydict[i] = 1
	else:
		mydict[i] += 1
ans = 0
for i in mydict:
	ans += mydict[i] - 1
if len(s) > 26:
	print(-1)
else:
	print(ans)


eng = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
n = int(input())
if n > 26:
	print(-1)
	exit()
a = input()
arr = []
for i in range(26):
	arr.append(0)
c = 0
for x in a:
	for i in range(26):
		if x == eng[i]:
			if arr[i] == 1:
				c += 1
			else:
				arr[i] += 1
print(c)


from sys import stdin, stdout

def test(n, s):
	dictionary = {}
	original = 'abcdefghijklmnopqrstuvwxyz'
	if n > 26:
		return -1
	repeated_chars = 0
	for char in s:
		if char in dictionary:
			repeated_chars += 1
		else:
			dictionary[char] = True
	return repeated_chars
n = int(stdin.readline().rstrip('\r\n'))
s = stdin.readline().rstrip('\r\n')
result = test(n, s)
stdout.write(str(result))


from sys import setrecursionlimit, exit
from math import ceil, floor, acos, pi
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce
setrecursionlimit(10 ** 8)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
MAX = 46
n = RI()[0]
s = RS()[0]
if len(s) > 26:
	print(-1)
else:
	print(n - len(set(list(s))))


n = int(input())
s = input()
sList = []
if n > 26:
	print(-1)
else:
	for i in range(n):
		sList.append(s[i])
	swaps = 0
	for i in range(n - 1):
		for j in range(i + 1, n):
			if sList[i] == sList[j]:
				sList[j] = swaps
				swaps += 1
	print(swaps)


f = lambda : map(int, input().split())
n = int(input())
s = input()
print(len(s) - len(set(s)) if len(s) - len(set(s)) <= 26 - len(set(s)) else -1)


n = int(input())
s = input()
a = ''
for i in s:
	if i not in a:
		a = a + i
k = 26 - len(a)
if len(s) - len(a) > k:
	print(-1)
else:
	print(len(s) - len(a))


__author__ = 'Utena'
n = int(input())
s = input()
t = 0
now = set()
if n > 26:
	print(-1)
else:
	for a in s:
		if a in now:
			t += 1
		else:
			now.add(a)
	print(t)


n = int(input())
a = input()
arr = [0] * 26
count = 0
for i in range(n):
	p = ord(a[i]) - ord('a')
	if arr[p] > 0:
		count = count + 1
	else:
		arr[p] = 1
if n > 26:
	print(-1)
else:
	print(count)


n = int(input())
a = list(str(input()))
e = 0
s = 0
for i in range(97, 97 + 26):
	e = a.count(str(chr(i)))
	if e != 0:
		s += 1
if n > 26:
	print(-1)
else:
	print(n - s)


n = int(input())
s = input()
d = {}
if len(s) > 26:
	cnt = -1
elif len(s) == 1:
	cnt = 0
else:
	for i in range(0, n):
		if s[i] in d:
			d[s[i]] += 1
		else:
			d[s[i]] = 1
	cnt = 0
	for (k, v) in d.items():
		if v > 1:
			cnt += v - 1
print(cnt)


import sys
n = int(input())
s = input()
if n > 26:
	print('-1')
	sys.exit(0)
lets = set()
for x in s:
	lets.add(x)
print(len(s) - len(lets))


from collections import Counter

def main():
	n = int(input())
	c = Counter(input())
	max_allowed = ord('z') - ord('a') + 1
	unique = len(c)
	changes = 0
	for (_, v) in c.items():
		changes += v - 1
	if unique + changes > max_allowed:
		print(-1)
	else:
		print(changes)
main()


n = int(input())
x = input()
l = 0
c = []
for i in range(97, 123):
	if x.count(chr(i)) > 0 and c.count(chr(i)) == 0:
		c.append(chr(i))
if n <= 26:
	print(n - len(c))
else:
	print('-1')


k = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	print(k - len(set(s)))


n = int(input())
a = list(input())
s = 0
if n > 26:
	print(-1)
else:
	alp = [0 for i in range(26)]
	for i in range(n):
		alp[ord(a[i]) - ord('a')] += 1
	for i in alp:
		if i > 1:
			s += i - 1
	print(s)


test_case = input()
T = int(test_case)
string_test2 = input()
string_test2 = str(string_test2)
dictnict_len = len(''.join(set(string_test2)))
if dictnict_len == T:
	print(0)
else:
	diff = T - dictnict_len
	if diff > 26 - dictnict_len:
		print(-1)
	else:
		print(diff)


n = int(input())
st = input()
if n > 26:
	print(-1)
else:
	li = [0] * 26
	for i in range(n):
		ch = ord(st[i]) - 97
		li[ch] = li[ch] + 1
	total = 0
	count = 0
	for i in range(26):
		if li[i] == 0:
			count = count + 1
		else:
			total = total + (li[i] - 1)
	if total <= count:
		print(total)
	else:
		print(-1)


from collections import defaultdict
n = int(input())
S = input()
c = defaultdict(int)
if n > 26:
	print(-1)
else:
	count = 0
	for s in S:
		c[s] += 1
	for ss in 'abcdefghijklmnopqrstuvwxyz':
		if c[ss] != 0:
			count += c[ss] - 1
	print(count)


n = int(input())
s = input()
a = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
b = list()
for i in a:
	if i in s:
		if i not in b:
			b.append(i)
if len(s) > 26:
	print(-1)
else:
	print(len(s) - len(b))


from collections import Counter
try:
	while True:
		n = int(input())
		s = input()
		if n > 26:
			print(-1)
		else:
			c = Counter(s)
			print(sum(c.values()) - len(c))
except EOFError:
	pass


from collections import Counter
n = int(input())
s = input().strip()
if len(s) > 26:
	print(-1)
else:
	c = Counter(s)
	print(sum((i - 1 for i in c.values())))


n = int(input())
s = input()
sl = len(set(s))
if n > 26:
	print('-1')
else:
	print(n - sl)


n = int(input())
s = input()
length = len(s)
changes = 0
if length > 26:
	print(-1)
else:
	print(length - len(set(s)))


from collections import OrderedDict
n = int(input())
s = str(input())
l = len(s)
f = ''.join(OrderedDict.fromkeys(s))
if len(s) > 26:
	print('-1')
else:
	print(len(s) - len(f))


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	a = [0] * 26
	for char in s:
		index = ord(char) - 97
		a[index] += 1
	ans = 0
	for i in range(26):
		if a[i] > 0:
			ans += a[i] - 1
	print(ans)


n = int(input())
s = input()[:n]
freq1 = {}
for i in s:
	if i in freq1:
		freq1[i] += 1
	else:
		freq1[i] = 1
list1 = freq1.items()
if n - len(list1) > 26 - len(list1):
	print(-1)
else:
	print(n - len(list1))


size = int(input())
stringArray = list(str(input()))
distinctchars = list(set(stringArray))
removals = size - len(distinctchars)
if size > 26:
	print('-1')
else:
	print(removals)


import string
n = int(input())
s = str(input())
if n > 26:
	print(-1)
else:
	res = 0
	for i in string.ascii_lowercase:
		if sum((1 for c in s if c == i)) > 1:
			res += sum((1 for c in s if c == i)) - 1
	print(res)


n = int(input())
s = input()
syms = set(s)
if len(s) > 26:
	print(-1)
else:
	print(len(s) - len(syms))


length = int(input())
letter = input()
letter = list(letter)
L1 = len(letter)
unique = list(dict.fromkeys(letter))
L2 = len(unique)
if length > 26:
	print(-1)
else:
	print(L1 - L2)


import sys
import string

def main():
	n = int(sys.stdin.readline())
	s = sys.stdin.readline().strip()
	charset = set([i for i in s])
	if len(s) <= 26:
		print(len(s) - len(charset))
	else:
		print('-1')
main()


n = int(input())
s = input()
st = set()
cnt = 0
if n > 26:
	print(-1)
else:
	for i in range(len(s)):
		if s[i] in st:
			cnt = cnt + 1
			st.add(s[i])
		else:
			st.add(s[i])
	print(cnt)


n = int(input())
s = input()
s = s[:n]
lst_1 = []
count = 0
for i in s:
	if i not in lst_1:
		lst_1.append(i)
	else:
		count += 1
if len(s) < 1:
	count = -1
if len(lst_1) == 1 and len(s) > 26:
	count = -1
if len(s) > 26:
	count = -1
print(count)


n = int(input())
local = input()
data = []
record = [0] * 26
for i in local:
	record[ord(i) - ord('a')] = i
dis_car = 0
for i in record:
	if i != 0:
		dis_car += 1
if n > 26:
	print(-1)
	exit()
if n > 26 and dis_car == 26:
	print(-1)
	exit()
print(n - dis_car)


n = int(input())
s = input()
per = 0
a = 'abcdefghijklmnopqrstuvwxyz'
k = [0] * 26
if n > len(a):
	print('-1')
else:
	for i in range(n):
		x = a.index(s[i])
		k[x] += 1
		if k[x] > 1:
			per += 1
	print(per)


n = int(input())
s = input()
sa = []
d = 0
if n <= 26:
	for i in range(n):
		if s[i] not in sa:
			sa.append(s[i])
			if s.count(s[i]) > 1:
				d += s.count(s[i]) - 1
	print(d)
else:
	print(-1)


n = int(input())
s = input()
s = sorted(s)
x = 0
if n > 26:
	print('-1')
else:
	for i in range(0, n - 1):
		if s[i] == s[i + 1]:
			x += 1
		else:
			continue
	print(x)


n = int(input())
s = input()
se = set({})
for x in s:
	se.add(x)
if n <= 26:
	print(n - len(se))
else:
	print(-1)


l = int(input())
s = input()
uniqueS = ''
for ch in s:
	if uniqueS.find(ch) == -1:
		uniqueS += ch
if l > 26:
	print(-1)
else:
	print(l - len(uniqueS))


n = int(input())
string = input()
freq = [0] * 26
for i in string:
	freq[ord(i) - ord('a')] += 1
free = 0
repeated = 0
for i in range(len(freq)):
	if freq[i] == 0:
		free += 1
	elif freq[i] > 1:
		repeated += freq[i] - 1
if free >= repeated:
	print(repeated)
else:
	print(-1)


n = int(input())
s = input()
(a, l, k) = ({}, 0, 0)
for i in s:
	if i in a:
		a[i] += 1
	else:
		a[i] = 1
		l += 1
for i in a:
	k += a[i] - 1
if k > 26 - l:
	print(-1)
else:
	print(k)


n = int(input())
s = input()
a = []
for i in range(26):
	a.append(0)
for i in s:
	a[ord(i) - ord('a')] += 1
p = []
for i in range(26):
	if a[i] == 0:
		p.append(chr(i + ord('a')))
s = list(s)
ans = 0
for i in range(n):
	if len(p) == 0:
		break
	if a[ord(s[i]) - ord('a')] > 1:
		a[ord(s[i]) - ord('a')] -= 1
		s[i] = p[len(p) - 1]
		p.pop()
		ans += 1
a = []
for i in range(26):
	a.append(0)
for i in s:
	a[ord(i) - ord('a')] += 1
for i in a:
	if i > 1:
		print(-1)
		exit()
print(ans)


n = int(input())
s = input()
a = [0] * 256
for i in s:
	a[ord(i)] = a[ord(i)] + 1
t = 0
c = 0
for i in a:
	if i != 0:
		t += 1
		c = c + (i - 1)
if t + c > 26:
	print(-1)
else:
	print(c)


from sys import stdin
input = stdin.readline
n = int(input())
s = input().rstrip('\n')
m = set()
for i in s:
	m.add(i)
if len(s) > 26:
	print(-1)
else:
	print(len(s) - len(m))


n = int(input())
s = input()
arr = set()
for i in range(n):
	arr.add(s[i])
if n - len(arr) < 26 and n <= 26:
	print(n - len(arr))
else:
	print(-1)


n = int(input())
if n >= 27:
	print(-1)
	quit()
s = input()
ans = []
a = set()
cnt = 0
for i in range(n):
	a.add(s[i])
print(n - len(a))


n = int(input())
s = input()
letters = [x for x in s]
letter = set(letters)
if n > 26:
	print(-1)
else:
	print(n - len(letter))


n = int(input())
string = input()
if n > 26:
	print(-1)
else:
	char_dict = {}
	for i in string:
		if i in char_dict.keys():
			char_dict[i] = char_dict[i] + 1
		else:
			char_dict[i] = 1
	characters_to_change = 0
	for (key, value) in char_dict.items():
		characters_to_change = characters_to_change + value - 1
	print(characters_to_change)


x = int(input())
n = input()
m = set(n)
if len(n) > 26:
	print('-1')
else:
	print(len(n) - len(m))


n = int(input())
s = input()
if len(s) > 26:
	print(-1)
else:
	st = set(s)
	print(n - len(st))


a = int(input(''))
b = input('')
l = 0
p = 0
th = 0
x = []
t = []
if a > 26:
	print(-1)
else:
	for k in range(a):
		x.append(b[l])
		l = l + 1
	for i in range(len(b)):
		if not b[p] in t:
			t.append(b[p])
		p = p + 1
	print(len(x) - len(t))


import sys
input = sys.stdin.readline
n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	print(len(s) - len(set(s)))


n = int(input())
s = input()
l = list(s)
p = set(l)
if len(s) > 26:
	print(-1)
elif len(p) < len(l):
	print(len(l) - len(p))
else:
	print(0)


n = int(input())
str = list(input())
counts = [0] * 26
changes_left = 26 - len(list(set(str)))
alphabet = 'abcdefghijklmnopqrstuvwxyz'
for c in range(len(alphabet)):
	counts[c] += max(0, str.count(alphabet[c]) - 1)
if sum(counts) > changes_left:
	print(-1)
else:
	print(sum(counts))


n = int(input())
string = input()
test = {}
for i in string:
	if not i in test:
		test[i] = 1
	else:
		test[i] += 1
res = 0
if len(string) > 26:
	print(-1)
else:
	print(len(string) - len(test))


from collections import Counter
n = int(input().strip())
s = input().strip()

def solve(s):
	freq = Counter(s)
	l = len(freq.keys())
	c = 0
	for i in freq.values():
		if i > 1:
			l += i - 1
			c += i - 1
		if l > 26:
			return -1
	return c
print(solve(s))


import sys
n = int(sys.stdin.readline())
s = sys.stdin.readline().strip()
if n > 26:
	ans = -1
else:
	letters = {}
	ans = 0
	for ch in s:
		try:
			letters[ch] += 1
			ans += 1
		except:
			letters[ch] = 1
print(ans)


x = int(input())
print(x - len(set(input())) if x < 27 else -1)


n = int(input())
a = input()
a = list(a)
c = 0
a.sort()
if n > 26:
	print(-1)
else:
	for i in range(n - 1):
		if a[i] == a[i + 1]:
			c += 1
	print(c)


n = int(input())
word = input()
dic = {}
for k in word:
	if k in dic:
		dic[k] += 1
	else:
		dic[k] = 1
s = 0
for j in dic:
	s += dic[j] - 1
if s > 26 - len(dic):
	print(-1)
else:
	print(s)


import math
n = int(input())
strng = input()
tmp_alph = 'qwertyuiopasdfghjklzxcvbnm'
alph = {}
count = 0
for elem in tmp_alph:
	alph[elem] = 0
if n > 26:
	print(-1)
else:
	for elem in strng:
		alph[elem] += 1
	for elem in alph.values():
		if elem > 1:
			count += elem - 1
	print(count)


n = int(input())
S = input()
l = n - len(set(S))
if l > 25 or n > 26:
	print(-1)
else:
	print(l)


def raznoobrazie(s):
	if len(s) > 26:
		return -1
	st = set()
	for i in range(len(s)):
		st.add(s[i])
	return len(s) - len(st)
n = int(input())
t = input()
print(raznoobrazie(t))


def diff(st):
	alph = 'abcdefghijklmnopqrstuvwxyz'
	to_add = [x for x in alph if x not in st]
	count = 0
	for x in st:
		if len(to_add) == 0:
			if len(st) == len(alph):
				break
			else:
				count = -1
				break
		if st.count(x) > 1:
			st = st.replace(x, to_add[0], 1)
			to_add.pop(0)
			count += 1
	return count

def main():
	n = int(input())
	st = input()
	print(diff(st))
main()


n = int(input())
b = len(set(list(input())))
if n < 27:
	print(n - b)
else:
	print('-1')


n = int(input())
s = input()
if n == 1:
	print(0)
	exit(0)
visited = set()
visited.add(s[0])
ans = 0
d = {}
d[s[0]] = 1
for i in range(1, n):
	if s[i] in visited:
		d[s[i]] += 1
	else:
		visited.add(s[i])
		d[s[i]] = 1
x = len(visited)
for i in d:
	x += d[i] - 1
	ans += d[i] - 1
if x > 26:
	print(-1)
else:
	print(ans)


x = int(input())
y = input()
l = []
rl = []
rrl = []
for i in y:
	l.append(i)
for i in l:
	if not i in rrl:
		rl.append(l.count(i))
	rrl.append(i)
if sum(rl) > 26:
	print(-1)
else:
	print(sum(rl) - len(rl))


(n, s) = (int(input()), input())
if len(s) > 26:
	print(-1)
	exit()
print(n - len(set(s)))


n = int(input())
if n > 26:
	print('-1')
	exit(0)
s = input()
a = []
ans = 0
for i in s:
	if not i in a:
		a.append(i)
	else:
		ans += 1
print(ans)


n = int(input())
s = input()
x = len(s)
l = set(s)
y = len(l)
if n > 26:
	print(-1)
else:
	print(x - y)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	ss = set(s)
	print(abs(len(ss) - len(s)))


def main():
	n = int(input())
	s = input()
	if n > 26:
		print(-1)
	else:
		d = {}
		x = 'a'
		for i in range(26):
			d[x] = 0
			x = chr(ord(x) + 1)
		for c in s:
			d[c] += 1
		ans = 0
		for k in d:
			if d[k] > 1:
				ans += d[k] - 1
		print(ans)
main()


from collections import Counter

def solution672b():
	_ = input()
	s = input().strip()
	if len(s) > 26:
		print(-1)
	else:
		iterations = 0
		counter = Counter(s)
		for c in counter.values():
			iterations += c - 1
		print(iterations)
solution672b()


n = int(input())
s = input()
x = s
d = {}
i = 0
while True:
	try:
		d[s[i]] = s.count(s[i]) - 1
		s = s.replace(s[i], '')
	except IndexError:
		break
counter = 0
for i in d:
	counter += d[i]
if len(x) > 26 and len(d) == 1 or len(x) > 26:
	print(-1)
else:
	print(counter)


n = int(input())
s = input()
l = list(set(s))
if n < 27:
	for i in range(len(l)):
		if s.count(l[i]) > 26:
			print(-1)
			break
	else:
		print(n - len(l))
else:
	print(-1)


def pos(ch):
	return ord(ch) - ord('a')
n = int(input())
str = input()
if n <= 26:
	isExist = [False] * 26
	count = 0
	for ch in str:
		if isExist[pos(ch)]:
			count += 1
		else:
			isExist[pos(ch)] = True
	print(count)
else:
	print(-1)


n = int(input())
s = input()
count = 0
z = [0] * 26
dis = 0
for i in range(n):
	z[ord(s[i]) - 97] += 1
for i in range(26):
	if z[i] > 1:
		count += z[i] - 1
	if z[i] > 0:
		dis += 1
if count > 26 - dis:
	print(-1)
else:
	print(count)


import sys
n = int(input())
string = input()
if n <= 26:
	alphabet = [0] * 26
	cnt = 0
	for char in string:
		alphabet[ord(char) - 97] += 1
	for num in alphabet:
		if num > 1:
			cnt += num - 1
	print(cnt)
else:
	print('-1')


n = int(input())
s = input().lower()[:n]
d = {}
for k in s:
	if k in d:
		d[k] += 1
	else:
		d[k] = 1
if n > 26:
	print(-1)
else:
	diff = n - len(d)
	print(diff)


import sys
import math
import bisect
import itertools
import random
import re

def main():
	n = int(input())
	A = set(list(input()))
	if n > 26:
		print(-1)
	else:
		ans = n - len(A)
		print(ans)
main()


t = int(input())
s = input()
x = set(s)
if t > 26:
	print('-1')
else:
	print(t - len(x))


n = int(input())
arr = input()
l = len(arr)
if l > 26:
	print(-1)
else:
	A = []
	for i in range(0, 26):
		A.append(0)
	for i in range(0, l):
		z = ord(arr[i]) - ord('a')
		A[z] += 1
	ans = 0
	for i in range(0, 26):
		if A[i] > 0:
			ans += A[i] - 1
	print(ans)


from sys import stdin
length = int(stdin.readline())
str = stdin.readline()
if length > 26:
	print(-1)
else:
	s = set()
	count = 0
	for spot in range(0, length):
		char = str[spot]
		if char in s:
			count += 1
		else:
			s.add(char)
	print(count)


from sys import stdin, stdout
inp = stdin.readline
out = stdout.write
n = int(inp())
if n > 0 and n < 27:
	s = inp()
	a = set(s)
	out(str(len(s) - len(a)))
else:
	out(str(-1))


n = int(input())
s = str(input().lower())
t = []
st = ''
if n > 26:
	print(-1)
else:
	for i in range(n):
		if s[i] not in t:
			t.append(s[i])
	for i in range(len(t)):
		st += t[i]
	print(n - len(st))


input()
a = list(input())
print(-1 if len(a) > 26 else len(a) - len(set(a)))


n = int(input())
s = input()
freq = [0] * 26
for i in s:
	freq[ord(i) - ord('a')] += 1
change = 0
for i in range(26):
	if freq[i]:
		change += freq[i] - 1
distinct = 0
for i in range(26):
	if freq[i]:
		distinct += 1
if distinct + change > 26:
	print(-1)
else:
	print(change)


n = input()
s = input()
l = []
l.extend(s)
if len(l) - len(set(l)) > 26 or len(l) > 26:
	print(-1)
else:
	print(len(l) - len(set(l)))


k = int(input())
a = input()
b = set()
e = 0
for i in range(k):
	if a[i] in b:
		e += 1
	else:
		b.add(a[i])
if k > 26:
	print(-1)
elif e > 25:
	print(-1)
else:
	print(e)


n = int(input())
s = input()
c = 0
if n > 26:
	print(-1)
else:
	for i in range(n):
		for j in range(i + 1, n):
			if s[i] == s[j]:
				c += 1
				break
	print(c)


input()
st = input()
db = {}
for char in st:
	if char in db:
		db[char] = db[char] + 1
	else:
		db[char] = 1
sm = 0
for k in db:
	sm += db[k]
print([sm - len(db), -1][sm > 26])


def main():
	n = int(input())
	s = input()
	arr = [0] * 26
	for char in s:
		arr[ord(char) - ord('a')] += 1
	ans = 0
	count = 0
	for c in range(26):
		if arr[c] > 0:
			count += 1
			ans += arr[c] - 1
	if 26 - count < ans:
		print(-1)
	else:
		print(ans)
main()


n = input()
(lambda x: print(-1 if len(x) > 26 else len(x) - len(set(x))))(input())


n = int(input())
s = input()
uni = set(s)
if len(s) > 26:
	print(-1)
else:
	print(len(s) - len(uni))


n = int(input())
s = str(input())
s1 = ''
count = 0
for i in range(n):
	if s1.find(s[i]) < 0:
		s1 += s[i]
	else:
		count += 1
if count + len(s1) > 26:
	print(-1)
else:
	print(count)


n = int(input())
a = input()
if n > 26:
	print(-1)
else:
	c = 0
	for i in range(97, 123):
		s = a.count(chr(i))
		if s > 1:
			c += s - 1
	print(c)


n = int(input())
str = str(input())
fr = [0] * 26
ans = 0
if len(str) > 26:
	ans = -1
else:
	for ch in str:
		fr[ord(ch) - ord('a')] += 1
	for i in fr:
		ans += max(1, i) - 1
print(ans)


from sys import *
n = int(input())
if n > 26:
	print(-1)
	exit(0)
s = input()
ee = set()
for i in s:
	ee.add(i)
print(n - len(ee))


n = int(input())
if n > 26:
	print(-1)
else:
	s = input().strip()
	sset = set([a for a in s])
	print(n - len(sset))


from collections import Counter
n = int(input())
s = input()
c = Counter(s)
diff = n - len(c)
if n > 26:
	print(-1)
else:
	print(diff)


n = int(input())
s = input()
m = 0
if n > 26:
	print(-1, end='')
else:
	myList = []
	for i in range(26):
		myList.append(0)
	for i in s:
		if myList[ord(i) - ord('a')] == 0:
			myList[ord(i) - ord('a')] = 1
		else:
			m += 1
	print(m)


n = int(input())
str = input()
if n > 26:
	print(-1)
else:
	count = []
	for i in range(26):
		count.append(0)
	for char in str:
		index = ord(char) - ord('a')
		count[index] = count[index] + 1
	total = 0
	for i in range(26):
		if count[i] != 0:
			total += count[i] - 1
	print(total)


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	distinct = len(set(s))
	if distinct == n:
		print(0)
	else:
		print(n - distinct)


n = int(input())
s = sorted(list(input()))
l = set(s)
ans = []
if n > 26:
	print(-1)
else:
	for i in l:
		ans.append(s.count(i))
	print(sum(ans) - len(ans))


v = int(input())
a = input()
d = {}
c = 0
for i in a:
	if i in d:
		d[i] += 1
		c += 1
	else:
		d[i] = 1
co = len(d)
if co + c > 26:
	c = -1
print(c)


n = int(input())
s = list(input())
import collections
q = collections.Counter(s)
s = 0
for i in q:
	if q[i] > 1:
		s += q[i] - 1
if s > 26 - len(q):
	print(-1)
else:
	print(s)


n = int(input())
l = [0 for i in range(0, 26)]
s = input()
nb = 0
d = 0
for e in 'abcdefghijklmnopqrstuvwxyz':
	t = s.count(e)
	if t > 1:
		nb += t - 1
	if t > 0:
		d += 1
	s = s.replace(e, '')
if 26 - d < nb:
	print(-1)
else:
	print(nb)


from collections import Counter
n = int(input())
s = input()
print(-1 if n > 26 else sum((x - 1 for x in Counter(s).values())))


n = int(input())
s = input()
if n > 26:
	print(-1)
else:
	has = [0] * 26
	for i in range(n):
		has[ord(s[i]) - ord('a')] += 1
	cop = 0
	con = 0
	for i in range(26):
		if has[i]:
			cop += has[i] - 1
		else:
			con += 1
	if con >= cop:
		print(cop)
	else:
		print(-1)


from collections import Counter
n = int(input())
s = input()
cnt = Counter(s)
res = 0
for i in cnt:
	if cnt[i] > 1:
		res += cnt[i] - 1
if res >= 26:
	print(-1)
	exit()
if res > 26 - len(cnt):
	print(-1)
	exit()
print(res)


from collections import Counter
n = int(input())
a = input()
if n > 26:
	print(-1)
	exit(0)
ans = 0
for i in Counter(a).values():
	ans += i - 1
print(ans)


def main():
	n = int(input())
	s = input()
	if len(s) > 26:
		print(-1)
		return
	unique = []
	for c in s:
		if c not in unique:
			unique.append(c)
	print(-1 if n - len(unique) < 0 else n - len(unique))
main()


n = int(input())
word = input()
if 1 <= n <= 100000:
	if n < 27:
		letters = []
		for i in range(n):
			counter = 0
			for j in range(len(letters)):
				if word[i] == letters[j]:
					counter += 1
			if counter == 0:
				letters.append(word[i])
		difference = n - len(letters)
		print(difference)
	else:
		print('-1')


n = int(input())
s = input()
a = [0] * 50
ans = 0
for i in s:
	tmp = ord(i) - ord('a')
	if a[tmp] == 0:
		a[tmp] = 1
	else:
		ans += 1
if n > 26:
	print(-1)
else:
	print(ans)