def f(s,c):
    al=0
    ar=0
    sl=[]
    sr=[]
    if(len(s)==1):
        return(int(s[0]!=c))
    for i in range(round(len(s)/2)):
        sl.append(s[i])
        ar+=int(s[i]!=c)
    for i in range(round(len(s)/2),len(s)):
        sr.append(s[i])
        al+=int(s[i]!=c)
    return(min( al+f(sl,chr(ord(c)+1)) , ar+f(sr,chr(ord(c)+1)) ))
t=int(input())
for tt in range(t):
    n=int(input())
    s=input()
    a=[]
    for i in range(n):
        a.append(s[i])
    print(f(s,'a'))