def solve(s,n,c):
	if n == 1:
		if s[0] != c:
			return 1
		return 0

	c1 = 0
	for i in range(0,n//2):
		if s[i] != c:
			c1 += 1
	c2 = 0
	for i in range(n//2,n):
		if s[i] != c:
			c2 += 1

	c = chr(ord(c)+1)
	a = c1 + solve(s[n//2:],n//2,c)
	b = c2 + solve(s[:n//2],n//2,c)
	return min(a,b)

for _ in range(int(input())):
	n = int(input())
	s = input()
	print( solve(s,n,'a') )
	