import sys
input = sys.stdin.readline
t = int(input())
letter = 'abcdefghijklmnopqrstuvwxyz'
def good(n,s,c):
    first = 0
    second = 0
    ans = 0
    #print("ans:",pee[0])
    if n==1 and s[0]==letter[c]:
        return 0
    elif n==1 and s[0]!=letter[c]:
        return 1
    for i in range(n//2):
        if s[i] == letter[c]:
            first+=1
    for i in range(n//2,n):
        if s[i]==letter[c]:
            second+=1
    if first>second:
        #print(second,s[n//2:n],c+1)
        return good(n//2,s[n//2:n],c+1)+(n//2-first)
    elif first<second:
        #print(first,s[:n//2],c+1)
        return good(n//2,s[:n//2],c+1)+(n//2-second)
    else:
        return min(good(n//2,s[:n//2],c+1),good(n//2,s[n//2:n],c+1))+(n//2-first)
for _ in range(t):
    n = int(input())
    s = list(input())
    pee = [0]
    ans = good(n,s,0)
    print(ans)
        
