# cook your dish here
from sys import stdin,stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I=lambda: map(int,stdin.readline().split())
I1=lambda: stdin.readline()

def fun(s,l,i,n):
    if n==1:
        if s==l[i]: return 0
        else: return 1 
    x=s[:n//2]
    y=s[n//2:]
    #print(x,y)
    c1=x.count(l[i])
    c2=y.count(l[i])
    a=n//2 -c1+fun(y,l,i+1,n//2)
    b=n//2 -c2+fun(x,l,i+1,n//2)
    return min(a,b)
    
    
    
for _ in range(int(I1())):
    n=int(I1())
    s=I1().strip()
    l='abcdefghijklmnopqrstuvwxyz'
    r=fun(s,l,0,n)
    print(r)
    