def helper(s,i):
    if len(s)==1:
        if ord(s)==i:
            return 0
        else:
            return 1
    mid=len(s)//2
    ans1=0
    for j in s[:mid]:
        if j!=chr(i):
            ans1+=1
    ans1+=helper(s[mid:],i+1)
    ans2=0
    for j in s[mid:]:
        if j!=chr(i):
            ans2+=1
    ans2+=helper(s[:mid],i+1)
    return min(ans1,ans2)
        

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(helper(s,ord('a')))