from math import *
from collections import *
from bisect import *
import sys
input=sys.stdin.readline
t=int(input())
def recfk(l,r,val,char):
    #print(l,r,char,val)
    global gl
    if(ord(char)>=97+18-1 or r-l<=0):
        return
    if(r-l==1):
        nex=chr(ord(char)+1)
        lis=[s[l],s[r]]
        if(lis.count(char)==2 or lis.count(nex)==2):
            gl.append(val+1)
        elif(char in lis and nex in lis):
            gl.append(val)
        elif(char in lis or nex in lis):
            gl.append(val+1)
        else:
            gl.append(val+2)
        return
    #print(char)
    #print(l,r//2,chr(ord(char)+1))
    mid=(l+r)//2
    lc=bisect_right(ind[char],mid)-bisect_left(ind[char],l)
    rc=bisect_right(ind[char],r)-bisect_left(ind[char],mid+1)
    lc=max(0,lc)
    rc=max(0,rc)
    recfk(l,mid,((r-l+1)//2)-rc+val,chr(ord(char)+1))
    recfk(mid+1,r,((r-l+1)//2)-lc+val,chr(ord(char)+1))
while(t):
    global gl
    t-=1
    n=int(input())
    s=input().rstrip("\n")
    if(n==1):
        if(s[0]=='a'):
            print(0)
        else:
            print(1)
        continue
    gl=[]
    ind={chr(i+97):[] for i in range(26)}
    for i in range(n):
        ind[s[i]].append(i)
    #print(ind)
    recfk(0,n-1,0,'a')
    try:
        print(min(gl))
    except:
        print(0)
    
