def s_half(string, c):
	score = 0
	for s in string:
		if s != c:
			score += 1
	return score

def sp1_half(string, c):
	score = 0
	if len(string) == 1:
		if string != c:
			score += 1
		return score
	
	l = string[:int(len(string)/2)]
	r = string[int(len(string)/2):]
	ls = s_half(l, c)
	lsp1 = sp1_half(l, chr(ord(c) + 1))
	rs = s_half(r, c)
	rsp1 = sp1_half(r, chr(ord(c) + 1))

	if ls + rsp1 <= rs + lsp1:
		return ls + rsp1
	else:
		return rs + lsp1

t = input()
for i in range(0, int(t)):
	n = input()
	s = input()
	score = sp1_half(s, 'a')
	print(score)