def calc(s, c):
	if len(s) == 1:
		if s[0] != c:
			return 1
		else:
			return 0
	l = 0
	r = len(s)
	mid = (l+r) // 2
	cntl = calc(s[mid:r], chr(ord(c)+1))
	cntl += (r-l) // 2 - s[l:mid].count(c)
	cntr = calc(s[l:mid], chr(ord(c)+1))
	cntr += (r-l) // 2 - s[mid:r].count(c)
	return min(cntl, cntr)

for _ in range(int(input())):
	n = int(input())
	string = input()
	print(calc(string, 'a'))
