import math
import sys
LI = lambda: list(map(int,input().split()) )
MI = lambda: map(int,input().split())
SI = lambda: input()
II = lambda: int(input())
t = II()
for q in range(t):
	n = II()
	s = SI()
	d = [0]*26
	dp = [0]*n
	def rec(a,z):
		if len(a) == 0:
			return 0
		elif len(a) == 1:
			return int(a!=z)
		mid = len(a)//2
		l = a[:mid]
		r = a[mid:]
		f = (mid-l.count(z))+rec(r,chr(ord(z)+1))
		s = (mid-r.count(z))+rec(l,chr(ord(z)+1))
		return min(f,s)
	print(rec(s,"a"))