def rec(s,c):
    n=len(s)
    if n==2:
        if s[0]==c and s[1]==chr(ord(c)+1):
            return 0
        elif s[1]==c and s[0]==chr(ord(c)+1):
            return 0
        elif s[0]==c or s[0]==chr(ord(c)+1):
            return 1
        elif s[1]==c or s[0]==chr(ord(c)+1):
            return 1
        else:
            return 2
    a1,a2=0,0
    for i in range(n//2):
        if s[i]!=c:
            a1+=1
    for i in range(n//2,n):
        if s[i]!=c:
            a2+=1
    an1=rec(s[n//2:],chr(ord(c)+1))+a1
    an2=rec(s[:n//2],chr(ord(c)+1))+a2
    return min(an1,an2)
    
t=int(input())
for q in range(t):
    n=int(input())
    s=input()
    if n==1:
        if s[0]=='a':
            print(0)
        else:
            print(1)
    else:
        print(rec(s,'a'))
