p='0abcdefghijklmnopqrstuvwxyz'

def sol(s,k):
    if len(s)==1:
        if s[0]==p[k]:
            return 0
        else:
            return 1
    l=0
    r=0
    for i in s[:len(s)//2]:
        if i!=p[k]:
            l+=1
    for i in s[len(s)//2:]:
        if i!=p[k]:
            r+=1
    return min(l+sol(s[len(s)//2:],k+1),r+sol(s[:len(s)//2],k+1))

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(sol(s,1))