def calc(s,l,r,ch):

	if r-l == 1 :

		if s[l] == ch:
			return 0
		else:
			return 1
	else:

		cnt1 = 0
		cnt2 = 0
		for i in range(l,(l+r)//2):

			if s[i] != ch:

				cnt1 += 1

		cnt_left = cnt1 + calc(s,(l+r)//2,r,chr(ord(ch)+1))

		for i in range((l+r)//2,r):
			if s[i] != ch:
				cnt2 += 1

		cnt_right = cnt2 + calc(s,l,(l+r)//2,chr(ord(ch)+1))

		return min(cnt_left,cnt_right)

t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	print(calc(s,0,n,"a"))










