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)
	cnt1 = (j-i)//2-left
	l = solve(s, i+(j-i)//2, j, chr(ord(char)+1), cnt+cnt1)
	cnt2 = (j-i)//2-right
	r = solve(s, i, i+(j-i)//2, chr(ord(char)+1), cnt+cnt2)
	return min(l, r)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(solve(s, 0, n, 'a', 0))