def solve(s, i, j, char, cnt):
	if j-i == 1:
		if s[i] == char:
			return cnt
		else:
			return cnt+1
	left = s[i:i+(j-i)//2].count(char)
	right = s[i+(j-i)//2:j].count(char)
	if left >= right:
		cnt += (j-i)//2-left
		return solve(s, i+(j-i)//2, j, chr(ord(char)+1), cnt)
	else:
		cnt += (j-i)//2-right
		return solve(s, i, i+(j-i)//2, chr(ord(char)+1), cnt)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(solve(s, 0, n, 'a', 0))