Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website considers a password to be strong if it satisfies the following criteria:

Its length is at least $\boldsymbol{6}$.  
It contains at least one digit.  
It contains at least one lowercase English character. 
It contains at least one uppercase English character. 
It contains at least one special character. The special characters are: !@#$%^&*()-+  

She typed a random string of length $n$ in the password field but wasn't sure if it was strong. Given the string she typed, can you find the minimum number of characters she must add to make her password strong?

Note: Here's the set of types of characters in a form you can paste in your solution:

numbers = "0123456789"
lower_case = "abcdefghijklmnopqrstuvwxyz"
upper_case = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
special_characters = "!@#$%^&*()-+"

Example  

$\textbf{password}=\textbf{'2bbbb'}$  

This password is 5 characters long and is missing an uppercase and a special character.  The minimum number of characters to add is $2$.  

$\textbf{password}=\textbf{'2bb#A'}$  

This password is 5 characters long and has at least one of each character type.  The minimum number of characters to add is $\mbox{1}$.    

Function Description  

Complete the minimumNumber function in the editor below.  

minimumNumber has the following parameters:  

int n:  the length of the password  
string password: the password to test  

Returns  

int:  the minimum number of characters to add  

Input Format

The first line contains an integer $n$, the length of the password.

The second line contains the password string. Each character is either a lowercase/uppercase English alphabet, a digit, or a special character.

Constraints

$1\leq n\leq100$  
All characters in $password$ are in [a-z], [A-Z], [0-9], or [!@#\$%^&*()-+ ].

Sample Input 0
3
Ab1

Sample Output 0
3

Explanation 0

She can make the password strong by adding $3$ characters, for example,  \$ hk, turning the password into Ab1\$hk which is strong. 

$2$ characters aren't enough since the length must be at least $\boldsymbol{6}$.  

Sample Input 1
11
#HackerRank

Sample Output 1
1

Explanation 1

The password isn't strong, but she can make it strong by adding a single digit.

Difficulty: EASY
Tags: String algorithms

Starter code:

Solutions:
import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	add = 0
	if all((n not in password for n in numbers)):
		add += 1
	if all((l not in password for l in lower_case)):
		add += 1
	if all((u not in password for u in upper_case)):
		add += 1
	if all((s not in password for s in special_characters)):
		add += 1
	return add + max(0, 6 - len(password) - add)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
input()
s = input()
ans = 0
found = any((i in numbers for i in s))
if not found:
	ans += 1
	s += '0'
found = any((i in lower_case for i in s))
if not found:
	ans += 1
	s += 'a'
found = any((i in upper_case for i in s))
if not found:
	ans += 1
	s += 'A'
found = any((i in special_characters for i in s))
if not found:
	ans += 1
	s += '!'
if len(s) < 6:
	ans += 6 - len(s)
print(ans)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	(nu, lc, uc, sc) = (0, 0, 0, 0)
	for letter in password:
		if letter in numbers:
			nu = 1
		if letter in lower_case:
			lc = 1
		if letter in upper_case:
			uc = 1
		if letter in special_characters:
			sc = 1
	return max(int(not nu) + int(not lc) + int(not uc) + int(not sc), 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	res1 = max(0, 6 - n)
	res2 = 0
	if not any((c in password for c in lower_case)):
		res2 += 1
	if not any((c in password for c in upper_case)):
		res2 += 1
	if not any((c in password for c in numbers)):
		res2 += 1
	if not any((c in password for c in special_characters)):
		res2 += 1
	return max(res1, res2)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
n = int(input())
s = input()
(bn, bl, bu, bs) = (False, False, False, False)
for c in s:
	if c in numbers:
		bn = True
	if c in lower_case:
		bl = True
	if c in upper_case:
		bu = True
	if c in special_characters:
		bs = True
res = 0
if not bn:
	res += 1
if not bl:
	res += 1
if not bu:
	res += 1
if not bs:
	res += 1
if len(s) < 6:
	res = max(res, 6 - len(s))
print(res)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
t = int(input())
il = input()
cnt = 0
for i in il:
	if i in numbers:
		cnt += 1
		break
for i in il:
	if i in lower_case:
		cnt += 1
		break
for i in il:
	if i in upper_case:
		cnt += 1
		break
for i in il:
	if i in special_characters:
		cnt += 1
		break
print(max(4 - cnt, 6 - t))


import sys

def minimumNumber(n, password):
	has_digit = False
	has_lc = False
	has_uc = False
	has_sc = False
	for ch in password:
		if ch >= '0' and ch <= '9':
			has_digit = True
		elif ch >= 'a' and ch <= 'z':
			has_lc = True
		elif ch >= 'A' and ch <= 'Z':
			has_uc = True
		elif ch in '!@#$%^&*()-+':
			has_sc = True
	ans = n
	if not has_digit:
		ans += 1
	if not has_lc:
		ans += 1
	if not has_uc:
		ans += 1
	if not has_sc:
		ans += 1
	if ans >= 6:
		return ans - n
	return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	chars = 0
	chars += 0 if any((c in numbers for c in password)) else 1
	chars += 0 if any((c in lower_case for c in password)) else 1
	chars += 0 if any((c in upper_case for c in password)) else 1
	chars += 0 if any((c in special_characters for c in password)) else 1
	return max(n + chars, 6) - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
l = input()
s = input()
ans = 0
done = 0
for i in s:
	if i in numbers:
		done = 1
if done == 0:
	ans += 1
done = 0
for i in s:
	if i in lower_case:
		done = 1
if done == 0:
	ans += 1
done = 0
for i in s:
	if i in upper_case:
		done = 1
if done == 0:
	ans += 1
done = 0
for i in s:
	if i in special_characters:
		done = 1
if done == 0:
	ans += 1
if len(s) + ans < 6:
	ans += 6 - len(s) - ans
print(ans)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	nu = sum((i in numbers for i in password))
	lo = sum((i in lower_case for i in password))
	up = sum((i in upper_case for i in password))
	sp = sum((i in special_characters for i in password))
	k = (nu == 0) + (lo == 0) + (up == 0) + (sp == 0)
	return max(k, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	s = password
	sc = '!@#$%^&*()-+'
	f1 = f2 = f3 = f4 = 0
	for ele in s:
		if ele.islower():
			f1 = 1
		if ele in sc:
			f2 = 1
		if ele.isupper():
			f3 = 1
		if ele >= '0' and ele <= '9':
			f4 = 1
	extra = 4
	extra -= f1 + f2 + f3 + f4
	if len(s) + extra >= 6:
		return extra
	else:
		return 6 - len(s)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input())
s = input()
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
ans = 0
for req in [numbers, lower_case, upper_case, special_characters]:
	for c in req:
		if c in s:
			break
	else:
		n += 1
		ans += 1
while n < 6:
	n += 1
	ans += 1
print(ans)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	(e, l, u, s) = (True, True, True, True)
	for x in password:
		if x in numbers:
			e = False
		elif x in lower_case:
			l = False
		elif x in upper_case:
			u = False
		elif x in special_characters:
			s = False
	return max(e + l + u + s, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	modsneeded = 0
	if sum((1 for c in password if c in '0123456789')) < 1:
		modsneeded += 1
	if sum((1 for c in password if c in 'abcdefghijklmnopqrstuvwxyz')) < 1:
		modsneeded += 1
	if sum((1 for c in password if c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')) < 1:
		modsneeded += 1
	if sum((1 for c in password if c in '!@#$%^&*()-+')) < 1:
		modsneeded += 1
	if n + modsneeded < 6:
		modsneeded = 6 - n
	return modsneeded
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
has = [0, 0, 0, 0]
n = int(input())
s = input()
for l in s:
	if l in numbers:
		has[0] = 1
	elif l in lower_case:
		has[1] = 1
	elif l in upper_case:
		has[2] = 1
	elif l in special_characters:
		has[3] = 1
to_add = 0
for x in has:
	if not x:
		to_add += 1
		n += 1
if n < 6:
	print(6 - n + to_add)
else:
	print(to_add)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	test1 = False
	test2 = False
	test3 = False
	test4 = False
	for c in password:
		if c in numbers:
			test1 = True
		elif c in lower_case:
			test2 = True
		elif c in upper_case:
			test3 = True
		elif c in special_characters:
			test4 = True
	needed = 0
	if not test1:
		needed += 1
	if not test2:
		needed += 1
	if not test3:
		needed += 1
	if not test4:
		needed += 1
	if 6 - n < needed:
		return needed
	else:
		return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	(c1, c2, c3, c4) = (0, 0, 0, 0)
	for c in password:
		c1 += 1 if c in numbers else 0
		c2 += 1 if c in lower_case else 0
		c3 += 1 if c in upper_case else 0
		c4 += 1 if c in special_characters else 0
	count = 0
	count += 1 if c1 > 0 else 0
	count += 1 if c2 > 0 else 0
	count += 1 if c3 > 0 else 0
	count += 1 if c4 > 0 else 0
	a1 = max(0, 4 - count)
	diff = max(0, 6 - len(password))
	return max(a1, diff)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
n = int(input())
s = input()
a = 0
b = 0
c = 0
d = 0
for i in s:
	if a == 0 and i in numbers:
		a = 1
	elif b == 0 and i in lower_case:
		b = 1
	elif c == 0 and i in upper_case:
		c = 1
	elif d == 0 and i in special_characters:
		d = 1
a = [a, b, c, d]
count = 0
for i in a:
	if i == 0:
		count += 1
if n + count < 6:
	print(6 - n)
else:
	print(count)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	n_bool = 1
	l_bool = 1
	u_bool = 1
	s_bool = 1
	for c in password:
		if c in numbers:
			n_bool = 0
		elif c in lower_case:
			l_bool = 0
		elif c in upper_case:
			u_bool = 0
		elif c in special_characters:
			s_bool = 0
	return max(6 - n, n_bool + l_bool + u_bool + s_bool)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
n = int(input())
a = input()
f = [0] * 4
ans = 0
for i in a:
	if i in numbers:
		f[0] = 1
	elif i in lower_case:
		f[1] = 1
	elif i in upper_case:
		f[2] = 1
	elif i in special_characters:
		f[3] = 1
print(max(6 - len(a), 4 - sum(f)))


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	extra = 0
	if set(password).isdisjoint(numbers):
		extra += 1
	if set(password).isdisjoint(lower_case):
		extra += 1
	if set(password).isdisjoint(upper_case):
		extra += 1
	if set(password).isdisjoint(special_characters):
		extra += 1
	if n + extra < 6:
		extra += 6 - (n + extra)
	return extra
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	answer = 0
	if all((c not in numbers for c in password)):
		answer += 1
	if all((c not in lower_case for c in password)):
		answer += 1
	if all((c not in upper_case for c in password)):
		answer += 1
	if all((c not in special_characters for c in password)):
		answer += 1
	answer += max(0, 6 - n - answer)
	return answer
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	upper = False
	lower = False
	digit = False
	special = False
	out = 0
	for c in password:
		if c in numbers:
			digit = True
		if c in lower_case:
			lower = True
		if c in upper_case:
			upper = True
		if c in special_characters:
			special = True
	if not digit:
		out += 1
	if not lower:
		out += 1
	if not upper:
		out += 1
	if not special:
		out += 1
	if n + out < 6:
		out = 6 - n
	return out
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	a = any((l in password for l in lower_case))
	b = any((l in password for l in upper_case))
	c = any((l in password for l in special_characters))
	d = any((l in password for l in numbers))
	cond = sum((a, b, c, d))
	toadd1 = 4 - cond
	toadd2 = max(0, 6 - len(password))
	return max(toadd1, toadd2)
n = int(input())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	count = 0
	for c in numbers:
		if c in password:
			break
	else:
		count += 1
	for c in lower_case:
		if c in password:
			break
	else:
		count += 1
	for c in upper_case:
		if c in password:
			break
	else:
		count += 1
	for c in special_characters:
		if c in password:
			break
	else:
		count += 1
	return max(count, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	(low, up, dig, spec) = (0, 0, 0, 0)
	for x in password:
		if x in numbers:
			dig += 1
		if x in lower_case:
			low += 1
		if x in upper_case:
			up += 1
		if x in special_characters:
			spec += 1
	letters_need = 0
	if dig == 0:
		letters_need += 1
	if low == 0:
		letters_need += 1
	if up == 0:
		letters_need += 1
	if spec == 0:
		letters_need += 1
	if n + letters_need < 6:
		letters_need = 6 - n
	return letters_need
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	res2 = 4
	for lower in lower_case:
		if lower in password:
			res2 -= 1
			break
	for lower in upper_case:
		if lower in password:
			res2 -= 1
			break
	for lower in special_characters:
		if lower in password:
			res2 -= 1
			break
	for lower in numbers:
		if lower in password:
			res2 -= 1
			break
	res1 = 6 - (n + res2)
	if res1 < 0:
		return res2
	else:
		return res1 + res2
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special = '!@#$%^&*()-+'
	used = [0, 0, 0, 0]
	for char in password:
		if char in numbers:
			used[0] = 1
		if char in lower_case:
			used[1] = 1
		if char in upper_case:
			used[2] = 1
		if char in special:
			used[3] = 1
	ans = 4
	for num in used:
		ans -= num
	if ans + n < 6:
		ans += 6 - ans - n
	return ans
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	cond = [1, 1, 1, 1]
	numbers = list('0123456789')
	lower_case = list('abcdefghijklmnopqrstuvwxyz')
	upper_case = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	special_characters = list('!@#$%^&*()-+')
	p = list(password)
	for i in p:
		if i in numbers:
			cond[0] = 0
		if i in lower_case:
			cond[1] = 0
		if i in upper_case:
			cond[2] = 0
		if i in special_characters:
			cond[3] = 0
	s = sum(cond)
	if n >= 6:
		return s
	elif n + s < 6:
		return 6 - n
	else:
		return s
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
input = sys.stdin.readline
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
length = int(input())
n = input().strip('\n')
low = 1
up = 1
spec = 1
num = 1
for letter in n:
	if letter in numbers:
		num = 0
	if letter in lower_case:
		low = 0
	if letter in upper_case:
		up = 0
	if letter in special_characters:
		spec = 0
toAdd = max(6 - len(n), int(num) + int(low) + int(up) + int(spec))
print(toAdd)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	ncase = False
	lcase = False
	ucase = False
	scase = False
	for x in range(n):
		l = password[x]
		if l in numbers:
			ncase = True
		if l in lower_case:
			lcase = True
		if l in upper_case:
			ucase = True
		if l in special_characters:
			scase = True
	y = sum([1 for i in [ncase, lcase, ucase, scase] if not i])
	if n + y >= 6:
		return y
	else:
		return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = set('0123456789')
lower_case = set('abcdefghijklmnopqrstuvwxyz')
upper_case = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
special_characters = set('!@#$%^&*()-+')

def count_req(s):
	num = 1
	lc = 1
	uc = 1
	sc = 1
	if any((c in numbers for c in s)):
		num = 0
	if any((c in lower_case for c in s)):
		lc = 0
	if any((c in upper_case for c in s)):
		uc = 0
	if any((c in special_characters for c in s)):
		sc = 0
	return num + lc + uc + sc

def main():
	n = int(input())
	s = input()
	extra = count_req(s)
	length = max(0, 6 - n)
	print(max(length, extra))
main()


import sys

def minimumNumber(n, password):
	numbers = set('0123456789')
	lower_case = set('abcdefghijklmnopqrstuvwxyz')
	upper_case = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	special_characters = set('!@#$%^&*()-+')
	pas = set(password)
	count = 0
	if len(numbers & pas) == 0:
		count += 1
	if len(lower_case & pas) == 0:
		count += 1
	if len(upper_case & pas) == 0:
		count += 1
	if len(special_characters & pas) == 0:
		count += 1
	return max(6 - n, count)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	values = [False, False, False, False, False]
	total = 0
	if len(password) >= 6:
		values[0] = True
	for i in password:
		if i in '0123456789':
			values[1] = True
		if i in 'abcdefghijklmnopqrstuvwxyz':
			values[2] = True
		if i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
			values[3] = True
		if i in '!@#$%^&*()-+':
			values[4] = True
	for i in values[1:]:
		if i == False:
			total += 1
	if values[0] == True:
		return total
	else:
		return max(total, 6 - len(password))
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
s = []
s.append(set('0123456789'))
s.append(set('ABCDEFGHIJKLMNOPQRSTUVWXYZ'))
s.append(set('abcdefghijklmnopqrstuvwxyz'))
s.append(set('!@#$%^&*()-+'))

def minimumNumber(n, password):
	symbs = set(password)
	missing = 0
	for si in s:
		missing += not symbs & si
	return max(missing, 6 - len(password))
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = list('0123456789')
	lower_case = list('abcdefghijklmnopqrstuvwxyz')
	upper_case = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	special_characters = list('!@#$%^&*()-+')
	lower = False
	upper = False
	number = False
	special = False
	for c in password:
		if not number and c in numbers:
			number = True
		elif not lower and c in lower_case:
			lower = True
		elif not upper and c in upper_case:
			upper = True
		elif not special and c in special_characters:
			special = True
	count = 0
	if not number:
		count += 1
	if not lower:
		count += 1
	if not upper:
		count += 1
	if not special:
		count += 1
	return max(count, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
import re

def minimumNumber(n, password):
	req = 4
	digit = False
	lower = False
	upper = False
	special = False
	for char in password:
		if char in '0123456789':
			digit = True
		if char in 'abcdefghijklmnopqrstuvwxyz':
			lower = True
		if char in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
			upper = True
		if char in '!@#$%^&*()-+':
			special = True
	if digit == True:
		req -= 1
	if lower == True:
		req -= 1
	if upper == True:
		req -= 1
	if special == True:
		req -= 1
	if n >= 6:
		return req
	else:
		return max(req, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	flag = 0
	for i in password:
		if i in numbers:
			numbers = ''
			flag += 1
		elif i in lower_case:
			lower_case = ''
			flag += 1
		elif i in upper_case:
			upper_case = ''
			flag += 1
		elif i in special_characters:
			special_characters = ''
			flag += 1
	return 4 - flag if 4 - flag > 6 - len(password) else 6 - len(password)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	nu = lc = uc = sc = False
	for p in password:
		nu |= p in numbers
		lc |= p in lower_case
		uc |= p in upper_case
		sc |= p in special_characters
	to_add = 4 - nu - lc - uc - sc
	if to_add + n < 6:
		to_add = 6 - n
	return to_add
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	lst = [0, 0, 0, 0]
	for ch in password:
		if lst[0] == 0 and ch in numbers:
			lst[0] = 1
		if lst[1] == 0 and ch in lower_case:
			lst[1] = 1
		if lst[2] == 0 and ch in upper_case:
			lst[2] = 1
		if lst[3] == 0 and ch in special_characters:
			lst[3] = 1
	need = 4 - sum(lst)
	return max(need, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	bool1 = bool2 = bool3 = bool4 = False
	count2 = 0
	if len(password) >= 6:
		count = 0
	else:
		count = 6 - len(password)
	for x in password:
		if x in numbers:
			bool1 = True
		if x in lower_case:
			bool2 = True
		if x in upper_case:
			bool3 = True
		if x in special_characters:
			bool4 = True
	if bool1 == False:
		count2 += 1
	if bool2 == False:
		count2 += 1
	if bool3 == False:
		count2 += 1
	if bool4 == False:
		count2 += 1
	return max(count, count2)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	small = 0
	big = 0
	digit = 0
	special = 0
	num = 0
	for i in range(n):
		if ord(password[i]) >= 65 and ord(password[i]) <= 90:
			big += 1
		elif ord(password[i]) >= 97 and ord(password[i]) <= 122:
			small += 1
		elif ord(password[i]) >= 48 and ord(password[i]) <= 57:
			digit += 1
		else:
			special += 1
	if small == 0:
		num += 1
	if big == 0:
		num += 1
	if digit == 0:
		num += 1
	if special == 0:
		num += 1
	num = num if num >= 6 - n else 6 - n
	return num
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	nos = list(numbers)
	lc = list(lower_case)
	uc = list(upper_case)
	sc = list(special_characters)
	vnos = 1
	vlc = 1
	vuc = 1
	vsc = 1
	p = list(password)
	for i in p:
		if i in nos:
			vnos = 0
		elif i in uc:
			vuc = 0
		elif i in lc:
			vlc = 0
		elif i in sc:
			vsc = 0
	if len(p) + vnos + vuc + vlc + vsc < 6:
		return 6 - len(p)
	return vnos + vuc + vlc + vsc
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	cond1 = 0
	cond2 = 1
	cond3 = 1
	cond4 = 1
	cond5 = 1
	if n >= 6:
		cond1 = 0
	else:
		cond1 = 6 - n
	for char in password:
		if char in numbers:
			cond2 = 0
		if char in lower_case:
			cond3 = 0
		if char in upper_case:
			cond4 = 0
		if char in special_characters:
			cond5 = 0
	if cond2 + cond3 + cond4 + cond5 > cond1:
		return cond2 + cond3 + cond4 + cond5
	return cond1
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	k = sum([int(not any([c in l for c in password])) for l in [numbers, lower_case, upper_case, special_characters]])
	if n + k < 6:
		return 6 - n
	return k
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input().strip())
password = input().strip()
ans = 4
for i in '!@#$%^&*()-+':
	if i in password:
		ans -= 1
		break
for i in 'abcdefghijklmnopqrstuvwxyz':
	if i in password:
		ans -= 1
		break
for i in 'abcdefghijklmnopqrstuvwxyz':
	if i.upper() in password:
		ans -= 1
		break
for i in '1234567890':
	if i in password:
		ans -= 1
		break
print(ans + max(0, 6 - n - ans))


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, p):
	s = 0
	s += not any((c in lower_case for c in p))
	s += not any((c in upper_case for c in p))
	s += not any((c in special_characters for c in p))
	s += not any((c in numbers for c in p))
	if s + n >= 6:
		return s
	else:
		return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	length = 4
	for i in numbers:
		if i in password:
			length -= 1
			break
	for i in lower_case:
		if i in password:
			length -= 1
			break
	for i in upper_case:
		if i in password:
			length -= 1
			break
	for i in special_characters:
		if i in password:
			length -= 1
			break
	temp = len(password)
	if 6 >= temp:
		return max(length, 6 - temp)
	else:
		return length
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	noSpecial = 1
	noDigit = 1
	noLower = 1
	noUpper = 1
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	for ele in numbers:
		if ele in password:
			noDigit = 0
	for ele in lower_case:
		if ele in password:
			noLower = 0
	for ele in upper_case:
		if ele in password:
			noUpper = 0
	for ele in special_characters:
		if ele in password:
			noSpecial = 0
	finalNumber = max(noDigit + noLower + noUpper + noSpecial, 6 - n)
	return finalNumber
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	mini = 0
	num = False
	low = False
	up = False
	spec = False
	if n < 6:
		mini = 6 - n
	for x in password:
		if x in numbers:
			num = True
		elif x in lower_case:
			low = True
		elif x in upper_case:
			up = True
		elif x in special_characters:
			spec = True
	defic = 0
	if num == False:
		defic += 1
	if low == False:
		defic += 1
	if up == False:
		defic += 1
	if spec == False:
		defic += 1
	if mini < defic:
		mini = defic
	return mini
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	addPos = {'useNumbers': 1, 'useLower': 1, 'useUpper': 1, 'useSpec': 1}
	for char in password:
		if char in numbers:
			addPos['useNumbers'] = 0
		if char in lower_case:
			addPos['useLower'] = 0
		if char in upper_case:
			addPos['useUpper'] = 0
		if char in special_characters:
			addPos['useSpec'] = 0
	sum = 0
	for val in addPos:
		sum += addPos[val]
	if sum + n >= 6:
		return sum
	else:
		return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input())
s = input()
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
a = 1
b = 1
c = 1
d = 1
for i in numbers:
	if i in s:
		a = 0
		break
for i in lower_case:
	if i in s:
		b = 0
		break
for i in upper_case:
	if i in s:
		c = 0
		break
for i in special_characters:
	if i in s:
		d = 0
		break
x = a + b + c + d
y = x + n
if y < 6:
	print(x + 6 - y)
else:
	print(x)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	count = 0
	if len(list(set(list(password)).intersection(list(numbers)))) == 0:
		count += 1
	if len(list(set(list(password)).intersection(list(lower_case)))) == 0:
		count += 1
	if len(list(set(list(password)).intersection(list(upper_case)))) == 0:
		count += 1
	if len(list(set(list(password)).intersection(list(special_characters)))) == 0:
		count += 1
	if len(password) + count < 6:
		count += 6 - (len(password) + count)
	return count
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	numbers_exist = not any(map(lambda c: c in numbers, password))
	lower_case_exist = not any(map(lambda c: c in lower_case, password))
	upper_case_exist = not any(map(lambda c: c in upper_case, password))
	special_characters_exist = not any(map(lambda c: c in special_characters, password))
	res = sum(map(int, [numbers_exist, lower_case_exist, upper_case_exist, special_characters_exist]))
	res += max(0, 6 - (res + n))
	return res
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	flag_digit = False
	flag_lower = False
	flag_upper = False
	flag_special = False
	for c in password:
		if c in '0123456789':
			flag_digit = True
		elif c in 'abcdefghijklmnopqrstuvwxyz':
			flag_lower = True
		elif c in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
			flag_upper = True
		elif c in '!@#$%^&*()-+':
			flag_special = True
	reqs = [flag_digit, flag_lower, flag_upper, flag_special].count(False)
	return max(max(6 - n, 0), reqs)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	flags = 0
	for c in password:
		if c in special_characters:
			flags |= 1
		elif c in numbers:
			flags |= 2
		elif c in lower_case:
			flags |= 4
		else:
			flags |= 8
		if flags == 15:
			break
	ret = 0
	for i in range(4):
		if 1 << i & flags == 0:
			ret += 1
	return max(6 - len(password), ret)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input())
s = input()
special = '!@#$%^&*()-+'
numbers = '0123456789'
if n < 6:
	req = 6 - n
else:
	req = 0
f = 0
ans = 0
for i in s:
	if i.isupper():
		f = 1
		break
if f == 0:
	ans += 1
else:
	f = 0
for i in s:
	if i.islower():
		f = 1
		break
if f == 0:
	ans += 1
else:
	f = 0
for i in s:
	if i in numbers:
		f = 1
		break
if f == 0:
	ans += 1
else:
	f = 0
for i in s:
	if i in special:
		f = 1
		break
if f == 0:
	ans += 1
else:
	f = 0
print(max(ans, req))


characters = ['0123456789', 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', '!@#$%^&*()-+']
n = int(input())
satistied = [False, False, False, False]
count = 4
s = input()
for character in s:
	for i in range(4):
		if not satistied[i] and character in characters[i]:
			count -= 1
			satistied[i] = True
print(max(count, 6 - n))


import sys

def minimumNumber(n, p):
	num = 1
	sp = 1
	cap = 1
	low = 1
	if len(p) >= 6:
		l = 0
	else:
		l = 6 - len(p)
	for i in range(len(p)):
		if p[i].isdigit():
			num = 0
		elif p[i].isupper():
			cap = 0
		elif p[i].islower():
			low = 0
		else:
			sp = 0
		if num == sp == cap == low == 0:
			break
	if l == 0:
		return num + sp + cap + low
	elif l >= num + sp + cap + low:
		return l
	else:
		return num + sp + cap + low
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	hasnumber = False
	for i in numbers:
		if i in password:
			hasnumber = True
			break
	haslc = False
	for i in lower_case:
		if i in password:
			haslc = True
			break
	hasuc = False
	for i in upper_case:
		if i in password:
			hasuc = True
			break
	hassc = False
	for i in special_characters:
		if i in password:
			hassc = True
			break
	need_more = 0
	if not hasnumber:
		need_more += 1
	if not haslc:
		need_more += 1
	if not hasuc:
		need_more += 1
	if not hassc:
		need_more += 1
	l = 6 - len(password)
	if l == need_more:
		return need_more
	elif l > need_more:
		return l
	else:
		return need_more
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	gerek = 4
	sayi = 0
	buyuk = 0
	kucuk = 0
	ozel = 0
	for i in password:
		if sayi == 0 and i in numbers:
			gerek -= 1
			sayi = 1
			continue
		elif buyuk == 0 and i in upper_case:
			gerek -= 1
			buyuk = 1
			continue
		elif kucuk == 0 and i in lower_case:
			gerek -= 1
			kucuk = 1
			continue
		elif ozel == 0 and i in special_characters:
			gerek -= 1
			ozel = 1
			continue
	if gerek > 6 - len(password):
		return gerek
	else:
		return 6 - len(password)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lowers = 'abcdefghijklmnopqrstuvwxyz'
uppers = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
specials = '!@#$%^&*()-+'

def minimumNumber(n, password):
	needed_for_length = max(0, 6 - len(password))
	needed_for_diversity = 0
	if not any([number in password for number in numbers]):
		needed_for_diversity += 1
	if not any([lower in password for lower in lowers]):
		needed_for_diversity += 1
	if not any([upper in password for upper in uppers]):
		needed_for_diversity += 1
	if not any([special in password for special in specials]):
		needed_for_diversity += 1
	return max(needed_for_length, needed_for_diversity)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input())
s = input().strip()
cnt = 0
di = 1
lo = 1
up = 1
sp = 1
sp_l = []
s2 = '!@#$%^&*()-+'
for i in s2:
	sp_l.append(i)
for i in s:
	cnt += 1
	if i.islower():
		lo = 0
	elif i.isupper():
		up = 0
	elif i.isdigit():
		di = 0
	elif i in sp_l:
		sp = 0
dane = lo + up + di + sp
if cnt >= 6:
	print(dane)
else:
	ans = max(dane, 6 - cnt)
	print(ans)


import sys
from string import punctuation

def minimumNumber(n, password):
	min_chars = 4
	if any((c.isdigit() for c in password)):
		min_chars -= 1
	if any((c.islower() for c in password)):
		min_chars -= 1
	if any((c.isupper() for c in password)):
		min_chars -= 1
	special_chars = set((c for c in '!@#$%^&*()-+'))
	if any((c in special_chars for c in password)):
		min_chars -= 1
	return max(min_chars, 6 - len(password))
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	nm = 1
	lc = 1
	uc = 1
	sc = 1
	for i in password:
		if i in numbers:
			nm = 0
		elif i in lower_case:
			lc = 0
		elif i in upper_case:
			uc = 0
		elif i in special_characters:
			sc = 0
	if n < 6:
		diff = 6 - n
	else:
		diff = 0
	return max(diff, nm + lc + uc + sc)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special = '!@#$%^&*()-+'
	hasno = 0
	lo = 0
	up = 0
	sp = 0
	for i in password:
		if i in numbers:
			hasno = 1
		elif i in lower_case:
			lo = 1
		elif i in upper_case:
			up = 1
		elif i in special:
			sp = 1
	cnt = lo + hasno + up + sp
	if cnt == 4:
		if n < 6:
			return 6 - n
		return 0
	if n > 6:
		return 4 - cnt
	if 6 - n > 4 - cnt:
		return 6 - n
	return 4 - cnt
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
import math

def minimumNumber(n, password):
	lower_case = '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'
	upper_case = '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'
	special = '! @ # $ % ^ & * ( ) - +'
	total = 0
	if not any((char.isdigit() for char in password)):
		total += 1
	if not any((char in list(special.split(' ')) for char in password)):
		total += 1
	if not any((char in list(upper_case.split(' ')) for char in password)):
		total += 1
	if not any((char in list(lower_case.split(' ')) for char in password)):
		total += 1
	if n < 6:
		total += max(6 - n - total, 0)
	return total
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	flags = [0] * 4
	for i in password:
		if i in numbers:
			flags[0] += 1
		elif i in lower_case:
			flags[1] += 1
		elif i in upper_case:
			flags[2] += 1
		elif i in special_characters:
			flags[3] += 1
	cnt = 0
	for i in flags:
		if i == 0:
			cnt += 1
	return max(6 - len(password), cnt)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
import sys

def minimumNumber(n, password):
	c2 = any((i in password for i in numbers))
	c3 = any((i in password for i in lower_case))
	c4 = any((i in password for i in upper_case))
	c5 = any((i in password for i in special_characters))
	c = sum(map(int, [c2, c3, c4, c5]))
	r = 4 - c
	if n + r < 6:
		r += 6 - n - r
	return r
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = set('0123456789')
	lower_case = set('abcdefghijklmnopqrstuvwxyz')
	upper_case = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	special_characters = set('!@#$%^&*()-+')
	extra_count = 0
	if not numbers.intersection(password):
		extra_count += 1
	if not lower_case.intersection(password):
		extra_count += 1
	if not upper_case.intersection(password):
		extra_count += 1
	if not special_characters.intersection(password):
		extra_count += 1
	return max(extra_count, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	num = False
	low = False
	upp = False
	sym = False
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	for c in password:
		if c in numbers:
			num = True
		elif c in lower_case:
			low = True
		elif c in upper_case:
			upp = True
		elif c in special_characters:
			sym = True
	count = 0
	if not num:
		count += 1
	if not low:
		count += 1
	if not upp:
		count += 1
	if not sym:
		count += 1
	return max(count, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	f1 = 0
	f2 = 0
	f3 = 0
	f4 = 0
	for i in range(n):
		if password[i] in numbers:
			f1 = 1
		if password[i] in lower_case:
			f2 = 1
		if password[i] in upper_case:
			f3 = 1
		if password[i] in special_characters:
			f4 = 1
	if n < 6:
		return max(4 - (f1 + f2 + f3 + f4), 6 - n)
	return 4 - (f1 + f2 + f3 + f4)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = set('0123456789')
lower_case = set('abcdefghijklmnopqrstuvwxyz')
upper_case = set('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
special_characters = set('!@#$%^&*()-+')

def minimumNumber(n, password):
	add = 0
	pa = set(password)
	if pa.intersection(numbers) == set():
		add += 1
	if pa.intersection(lower_case) == set():
		add += 1
	if pa.intersection(upper_case) == set():
		add += 1
	if pa.intersection(special_characters) == set():
		add += 1
	if len(password) + add < 6:
		return 6 - len(password)
	else:
		return add
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	need = 0
	chk = [False, False, False, False]
	for i in password:
		if i.isdigit():
			chk[0] = True
		if i in lower_case:
			chk[1] = True
		if i in upper_case:
			chk[2] = True
		if i in special_characters:
			chk[3] = True
	need = chk.count(False)
	if need + n < 6:
		need += 6 - need - n
	return need
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	a = list('0123456789')
	b = list('abcdefghijklmnopqrstuvwxyz')
	c = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	d = list('!@#$%^&*()-+')
	c1 = c2 = c3 = c4 = 0
	for i in range(n):
		if password[i] in a:
			c1 = 1
		elif password[i] in b:
			c2 = 1
		elif password[i] in c:
			c3 = 1
		else:
			c4 = 1
	return max(4 - c1 - c2 - c3 - c4, 6 - n)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, a):
	e = 1
	f = 1
	g = 1
	h = 1
	b = '!@#$%^&*()-+'
	c = '0123456789'
	if n >= 6:
		for i in a:
			if ord(i) <= 90 and ord(i) >= 65:
				e = 0
			elif ord(i) <= 122 and ord(i) >= 97:
				f = 0
			elif i in b:
				g = 0
			elif i in c:
				h = 0
			if e == 1 and f == 1 and (g == 1) and (h == 1):
				break
		return e + f + g + h
	elif n > 2:
		for i in a:
			if ord(i) <= 90 and ord(i) >= 65:
				e = 0
			elif ord(i) <= 122 and ord(i) >= 97:
				f = 0
			elif i in b:
				g = 0
			elif i in c:
				h = 0
			if e == 1 and f == 1 and (g == 1) and (h == 1):
				break
		return max(6 - n, e + f + g + h)
	else:
		return 6 - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	hasDigit = False
	hasLower = False
	hasUpper = False
	hasSpecial = False
	for c in password:
		if hasDigit == False and c in numbers:
			hasDigit = True
		if hasLower == False and c in lower_case:
			hasLower = True
		if hasUpper == False and c in upper_case:
			hasUpper = True
		if hasSpecial == False and c in special_characters:
			hasSpecial = True
		if hasDigit and hasLower and hasUpper and hasSpecial:
			break
	res = 0
	if hasDigit == False:
		res += 1
	if hasLower == False:
		res += 1
	if hasUpper == False:
		res += 1
	if hasSpecial == False:
		res += 1
	if n + res < 6:
		return 6 - n
	return res
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	l = n
	digit = 0
	lower = 0
	upper = 0
	special = 0
	for i in password:
		if i.isdigit():
			digit += 1
		elif i.islower():
			lower += 1
		elif i.isupper():
			upper += 1
		else:
			special += 1
	if not digit:
		l += 1
	if not upper:
		l += 1
	if not lower:
		l += 1
	if not special:
		l += 1
	if l < 6:
		return l - n + 6 - l
	else:
		return l - n
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


n = int(input())
s = input()
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
hasNum = 0
for char in numbers:
	if char in s:
		hasNum += 1
		break
hasLower = 0
for char in lower_case:
	if char in s:
		hasLower += 1
		break
hasUpper = 0
for char in upper_case:
	if char in s:
		hasUpper += 1
		break
hasSpecial = 0
for char in special_characters:
	if char in s:
		hasSpecial += 1
		break
lengthNeeded = 6
numNeeded = 4 - hasNum - hasLower - hasUpper - hasSpecial
if len(s) < lengthNeeded:
	print(max([lengthNeeded - len(s), numNeeded]))
else:
	print(numNeeded)


import sys

def minimumNumber(n, password):
	lower_case = False
	upper_case = False
	digit = False
	special = False
	for c in list(password):
		if c in list('abcdefghijklmnopqrstuvwxyz'):
			lower_case = True
		if c in list('ABCDEFGHIJKLMNOPQRSTUVWXYZ'):
			upper_case = True
		if c in list('0123456789'):
			digit = True
		if c in list('!@#$%^&*()-+'):
			special = True
	extra = 0
	if not lower_case:
		extra += 1
	if not upper_case:
		extra += 1
	if not digit:
		extra += 1
	if not special:
		extra += 1
	if n + extra < 6:
		return_val = 6 - n - extra + extra
	else:
		return_val = extra
	return return_val
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	minLength = 6
	toAdd = 0
	toAdd2 = 0
	if minLength > len(password):
		toAdd += minLength - len(password)
	if not any((a for a in numbers if a in password)):
		toAdd2 += 1
	if not any((a for a in lower_case if a in password)):
		toAdd2 += 1
	if not any((a for a in upper_case if a in password)):
		toAdd2 += 1
	if not any((a for a in special_characters if a in password)):
		toAdd2 += 1
	return max(toAdd, toAdd2)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	special_characters = '!@#$%^&*()-+'
	num = 0
	low = 0
	upp = 0
	spe = 0
	result = 0
	for i in password:
		if i.isdigit():
			num += 1
		elif i.islower():
			low += 1
		elif i.isupper():
			upp += 1
		elif i in special_characters:
			spe += 1
	if num == 0:
		result += 1
		n += 1
	if low == 0:
		result += 1
		n += 1
	if upp == 0:
		result += 1
		n += 1
	if spe == 0:
		result += 1
		n += 1
	if n < 6:
		result += 6 - n
	return result
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def contains(s, symbols):
	for c in s:
		if c in symbols:
			return True
	return False

def minimumNumber(n, s):
	res = 0
	if not contains(s, numbers):
		res += 1
	if not contains(s, lower_case):
		res += 1
	if not contains(s, upper_case):
		res += 1
	if not contains(s, special_characters):
		res += 1
	if len(s) + res < 6:
		res += 6 - (len(s) + res)
	return res
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	num = list('0123456789')
	small = list('abcdefghijklmnopqrstuvwxyz')
	large = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	sp = list('!@#$%^&*()-+')
	a = b = c = d = 0
	for i in range(0, n):
		if password[i] in num:
			a = 1
		if password[i] in small:
			b = 1
		if password[i] in large:
			c = 1
		if password[i] in sp:
			d = 1
	cnt = 4 - (a + b + c + d)
	if cnt + n < 6:
		return 6 - n
	else:
		return cnt
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	hasNum = False
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	hasLower = False
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	hasUpper = False
	special_characters = '!@#$%^&*()-+'
	hasSpecial = False
	add = 0
	for char in password:
		if char in numbers and hasNum == False:
			hasNum = True
		if char in lower_case and hasLower == False:
			hasLower = True
		if char in upper_case and hasUpper == False:
			hasUpper = True
		if char in special_characters and hasSpecial == False:
			hasSpecial = True
	if hasNum == False:
		add += 1
	if hasLower == False:
		add += 1
	if hasUpper == False:
		add += 1
	if hasSpecial == False:
		add += 1
	if add + n < 6:
		add += 6 - (add + n)
	return add
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	num_yn = 0
	low_yn = 0
	upp_yn = 0
	spe_yn = 0
	for char in password:
		if char in numbers:
			num_yn = 1
		if char in lower_case:
			low_yn = 1
		if char in upper_case:
			upp_yn = 1
		if char in special_characters:
			spe_yn = 1
	mis = 4 - (num_yn + low_yn + upp_yn + spe_yn)
	if n < 6:
		return max(6 - n, mis)
	else:
		return mis
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	done = [0] * 5
	done[4] = max(6 - n, 0)
	for p in password:
		if p in numbers:
			done[0] = 1
		if p in lower_case:
			done[1] = 1
		if p in upper_case:
			done[2] = 1
		if p in special_characters:
			done[3] = 1
	return max(4 - sum(done[0:4]), done[4])
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
specialcharacters = '!@#$%^&*()-+'

def has_rng_chr(password, lb, ub):
	for char in password:
		if ord(char) in range(lb, ub):
			return True
	return False

def has_number(password):
	return has_rng_chr(password, 48, 58)

def has_uc(password):
	return has_rng_chr(password, 65, 91)

def has_lc(password):
	return has_rng_chr(password, 97, 123)

def has_special(password):
	for char in password:
		if char in '!@#$%^&*()-+':
			return True
	return False

def minimumNumber(n, password):
	missing_types = 4 - (has_number(password) + has_uc(password) + has_lc(password) + has_special(password))
	return max(6 - n, missing_types)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	numbers = list(numbers)
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	lower_case = list(lower_case)
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	upper_case = list(upper_case)
	special_characters = '!@#$%^&*()-+'
	special_characters = list(special_characters)
	count = 0
	flag1 = False
	flag2 = False
	flag3 = False
	flag4 = False
	flag5 = False
	for i in range(n):
		if password[i] in numbers:
			flag2 = True
		if password[i] in lower_case:
			flag3 = True
		if password[i] in upper_case:
			flag4 = True
		if password[i] in special_characters:
			flag5 = True
	if not flag2:
		count += 1
		n += 1
	if not flag3:
		count += 1
		n += 1
	if not flag4:
		count += 1
		n += 1
	if not flag5:
		count += 1
		n += 1
	if n > 6:
		flag1 = True
	else:
		count += 6 - n
	return count
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	changes = 0
	sc_ok = False
	for i in special_characters:
		if i in password:
			sc_ok = True
			break
	if not sc_ok:
		password += '!'
		changes += 1
	upp_ok = False
	for i in upper_case:
		if i in password:
			upp_ok = True
			break
	if not upp_ok:
		password += 'A'
		changes += 1
	low_ok = False
	for i in lower_case:
		if i in password:
			low_ok = True
			break
	if not low_ok:
		password += 'a'
		changes += 1
	dig_ok = False
	for i in numbers:
		if i in password:
			dig_ok = True
			break
	if not dig_ok:
		password += '0'
		changes += 1
	length = len(password)
	if length < 6:
		changes += 6 - length
	return changes
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	(digit, lowercase, uppercase, special) = (1, 1, 1, 1)
	for i in range(n):
		if password[i] in lower_case:
			lowercase = 0
		elif password[i] in upper_case:
			uppercase = 0
		elif password[i] in numbers:
			digit = 0
		elif password[i] in special_characters:
			special = 0
	if n < 6:
		return max(6 - n, lowercase + uppercase + digit + special)
	else:
		return lowercase + uppercase + digit + special
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	nums = list('0123456789')
	lower = list('abcdefghijklmnopqrstuvwxyz')
	upper = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	special = list('!@#$%^&*()-+')
	u = False
	l = False
	s = False
	n = False
	for i in password:
		if i in upper:
			u = True
		elif i in lower:
			l = True
		elif i in special:
			s = True
		elif i in nums:
			n = True
	ls = len(password)
	count = 0
	if not u:
		count += 1
	if not l:
		count += 1
	if not s:
		count += 1
	if not n:
		count += 1
	diff = 0
	if count + ls < 6:
		diff = 6 - count - ls
	return count + diff
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, s):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	counter = 0
	small = 0
	cap = 0
	num = 0
	sp = 0
	for i in range(n):
		if s[i] in lower_case:
			small = 1
		elif s[i] in upper_case:
			cap = 1
		elif s[i] in numbers:
			num = 1
		elif s[i] in special_characters:
			sp = 1
	if small == 0:
		counter += 1
		n += 1
	if cap == 0:
		counter += 1
		n += 1
	if num == 0:
		n += 1
		counter += 1
	if sp == 0:
		n += 1
		counter += 1
	if n < 6:
		counter = counter + (6 - n)
	return counter
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'

def minimumNumber(n, password):
	num_lower = num_upper = num_digits = num_special = 0
	for c in password:
		if c in numbers:
			num_digits += 1
		elif c in lower_case:
			num_lower += 1
		elif c in upper_case:
			num_upper += 1
		elif c in special_characters:
			num_special += 1
	add = 0
	if num_digits == 0:
		add += 1
	if num_lower == 0:
		add += 1
	if num_upper == 0:
		add += 1
	if num_special == 0:
		add += 1
	if add + n < 6:
		add += 6 - (add + n)
	return add
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import os, sys

def main():
	lower = list('abcdefghijklmnopqrstuvwxyz')
	upper = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
	digits = list('1234567890')
	special = list('!@#$%^&*()-+')
	v_lower = 1
	v_upper = 1
	v_dig = 1
	v_spec = 1
	v_l = 0
	n = int(input().strip())
	password = input().strip()
	for p in password:
		if p in lower:
			v_lower = 0
		if p in upper:
			v_upper = 0
		if p in digits:
			v_dig = 0
		if p in special:
			v_spec = 0
	violations = v_lower + v_upper + v_dig + v_spec
	if len(password) >= 6:
		v_l = 0
	else:
		v_l = 6 - len(password) - v_lower - v_upper - v_dig - v_spec
		if v_l < 0:
			v_l = 0
	violations += v_l
	print(violations)
main()


import sys

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	has_numbers = 1
	has_lower_case = 1
	has_upper_case = 1
	has_special_characters = 1
	for i in password:
		if i in numbers:
			has_numbers = 0
		elif i in lower_case:
			has_lower_case = 0
		elif i in upper_case:
			has_upper_case = 0
		elif i in special_characters:
			has_special_characters = 0
		if has_numbers == 0 and has_lower_case == 0 and (has_upper_case == 0) and (has_special_characters == 0):
			break
	sum = has_special_characters + has_lower_case + has_upper_case + has_numbers
	return max(6 - n, sum)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


numbers = '0123456789'
lower_case = 'abcdefghijklmnopqrstuvwxyz'
upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
special_characters = '!@#$%^&*()-+'
n = int(input())
str = input()
f1 = f2 = f3 = f4 = 0
for char in str:
	if char in numbers:
		f1 = 1
	elif char in lower_case:
		f2 = 1
	elif char in upper_case:
		f3 = 1
	else:
		f4 = 1
print(max(6 - len(str), 4 - (f1 + f2 + f3 + f4)))


import sys

def need_one(password, chars):
	for c in chars:
		if c in password:
			return False
	return True

def minimumNumber(n, password):
	numbers = '0123456789'
	lower_case = 'abcdefghijklmnopqrstuvwxyz'
	upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	special_characters = '!@#$%^&*()-+'
	need = 0
	need += 1 if need_one(password, numbers) else 0
	need += 1 if need_one(password, lower_case) else 0
	need += 1 if need_one(password, upper_case) else 0
	need += 1 if need_one(password, special_characters) else 0
	if len(password) + need < 6:
		need += 6 - len(password) - need
	return need
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys
import re

def minimumNumber(n, password):
	count = 0
	if not bool(re.search('[\\!\\@\\#\\$\\%\\^\\&\\*\\(\\)\\-\\+]', password)):
		count += 1
	if not bool(re.search('[\\d]', password)):
		count += 1
	if not bool(re.search('[a-z]', password)):
		count += 1
	if not bool(re.search('[A-Z]', password)):
		count += 1
	if 6 - n > count:
		return 6 - n
	else:
		return count
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)


import sys

def minimumNumber(n, password):
	N = '0123456789'
	L = 'abcdefghijklmnopqrstuvwxyz'
	U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	S = '!@#$%^&*()-+'
	s = 4
	for a in N:
		if a in password:
			s -= 1
			break
	for a in L:
		if a in password:
			s -= 1
			break
	for a in U:
		if a in password:
			s -= 1
			break
	for a in S:
		if a in password:
			s -= 1
			break
	if n >= 6 and s == 0:
		return 0
	elif n >= 6:
		return s
	else:
		return max(6 - n, s)
n = int(input().strip())
password = input().strip()
answer = minimumNumber(n, password)
print(answer)