import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))

def find(a,c,d,p):
    if(len(a)==1):
        if(ord(a[0])==p):
            return(0)
        else:
            return(1)
    for i in range(0,len(a)//2):
        if(ord(a[i])!=p):
            c+=1
    for i in range(len(a)//2,len(a)):
        if(ord(a[i])!=p):
            d+=1
    c+=find(a[len(a)//2:],0,0,p+1)
    d+=find(a[0:len(a)//2],0,0,p+1)
    return(min(c,d))
def solve():
    n=I()
    a=input().strip()
    if(n==1):
        if(a=='a'):
            print(0)
        else:
            print(1)
        return
    p=find(a,0,0,97)
    print(p)
    
for _ in range(I()):
    solve()