import sys,math
from collections import deque
import random
#input = sys.stdin.buffer.readline


def f(x,h,c):
	# print(c, end=':')
	if len(x) == 1:
		if x[0]==c:
			#print(0)
			return 0
		else:
			#print(1)
			return 1

	if h==0:
		cnt = 0
		for i in range(len(x)//2):
			if not x[i] == c:
				cnt+=1
		# print(cnt)
		return cnt + min(f(x[len(x)//2:],0,chr(ord(c)+1)) , f(x[len(x)//2:],1,chr(ord(c)+1)))
	else:
		cnt = 0
		for i in range(len(x)//2,len(x)):
			if not x[i] == c:
				cnt+=1
		# print(cnt)
		return cnt + min(f(x[:len(x)//2],0,chr(ord(c)+1)) , f(x[:len(x)//2],1,chr(ord(c)+1)))

for i in range(int(input())):
	n = int(input())
	s = input()

	print(min(f(s,0,'a') , f(s,1,'a')))
