from sys import stdin
input = lambda: stdin.readline().rstrip("\r\n")
from collections import deque as que, defaultdict as vector
from heapq import*
inin = lambda: int(input())
inar = lambda: list(map(int,input().split()))
from math import log2
alp='abcdefghijklmnopqrstuvwxyz'
def solve(c,l,r,s):
	#print(c,l,r,s)
	mid=(l+r)//2
	c1=0
	c2=0
	ch=alp[c]
	if l==r-1:
		if ch==s[l]:
			return 0
		else:
			return 1
	for i in range(l,mid):
		if s[i]!=ch:
			c1+=1
	for i in range(mid,r):
		if s[i]!=ch:
			c2+=1
	return min(c1+solve(c+1,mid,r,s),c2+solve(c+1,l,mid,s))

	

Testcase=inin()
for i in range(Testcase):
	n=inin()
	s=input()
	k=int(log2(n)+1)
	print(solve(0,0,n,s))