from functools import lru_cache
from sys import stdin, stdout
import sys
from math import *

# from collections import deque
# sys.setrecursionlimit(int(1e3))
# input = stdin.buffer.readline
# print = stdout.write

def count(i,j,c):
	ans=0
	for x in range(i,j):
		if(s[x]!=c):
			ans+=1
	return ans

lru_cache(None)
def func(c,i,j):
	# print(c,i,j,tt)
	if(i+1==j):
		if(s[i]==c):
			return 0
		else:
			return 1
	else:
		temp1=func(chr(ord(c)+1),i,i+(j-i)//2)
		# print("asdf")
		temp2=func(chr(ord(c)+1),i+ceil((j-i)/2),j)
		t1=count(i,i+(j-i)//2,c)
		t2=count(i+ceil((j-i)/2),j,c)
		return min(temp2+t1,temp1+t2)



for __ in range(int(input())):
	n=int(input())
	s=input()
	tt=len(bin(n)[2:])
	a=func(chr(97),0,n)
	print(a)


