def solve(s,c):
    if len(s) == 1:
        return 0 if s[0] == c else 1
    

    ## making it of the form cccccc.... goodstring
    s1=s[:len(s)//2]
    s2=s[len(s)//2:]

    cnt1 = s1.count(c)
    cnt2= s2.count(c)
    
    ans1=solve(s1,chr(ord(c)+1))
    ans2=solve(s2,chr(ord(c)+1))
    n=len(s)//2
    return min(n-cnt1+ans2,n-cnt2+ans1)

    ##making it of the form ......cccccc good string 


for _ in range(int(input())):
    n=int(input())
    # n,m=[int(c) for c in input().split()]
    # arr=[int(c) for c in input().split()]
    s=input()
    print(solve(s,'a'))

