#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

########################################

s = ""

def dp(l,r,c):
	if l == r:
		return s[l]!=c
	m = (l+r)//2
	ans1 = dp(m+1,r,chr(ord(c)+1))
	ans2 = dp(l,m,chr(ord(c)+1))
	for i in range(l,m+1):
		ans1+= s[i]!=c
	for i in range(m+1,r+1):
		ans2+= s[i]!=c
	return min(ans1,ans2)
	
	
	
for ii in range(int(input())):
	n = int(input())
	s = input()
	print(int(dp(0,n-1,"a")))
	






