from sys import stdin,stdout
stdin.readline
def mp(): return list(map(int, stdin.readline().strip().split()))
def it():return int(stdin.readline().strip())
from collections import defaultdict as dd,Counter as C,deque
from math import ceil

def getcost(s,l,r,c):
	count=0
	for i in range(l,r+1):
		if s[i]!=c:
			count+=1
	return count

def fun(s,l,r,c):
	if l == r:
		if s[l] == c:
			return 0
		return 1
	mid = (l+r)//2
	return min(getcost(s,l,mid,chr(ord(c))) + fun(s,mid+1,r,chr(ord(c)+1)) , getcost(s,mid+1,r,chr(ord(c))) + fun(s,l,mid,chr(ord(c)+1)))


for _ in range(it()):
	n = it()
	s = list(input())
	x = 'a'
	ans = fun(s,0,n-1,x)
	print(ans)

