
def tits(s,c):
	if len(s)==1:
		if s[0]==c:
			return 0
		else:
			return 1
	c1 = s[0:len(s)//2].count(c)
	c2 = s[len(s)//2 :].count(c)
	
	return min(len(s)//2 - c1 + tits(s[len(s)//2:], chr(ord(c)+1)) ,len(s)//2 - c2 + tits(s[:len(s)//2], chr(ord(c)+1)))
for i in range(int(input())):
	n = int(input())
	s = input()
	print(tits(s,"a"))



