def sol(s,n,c):
    if n==1:
        if s[0]==c:
            return 0
        else:
            return 1
    s1=s[0:n//2]
    s2=s[n//2:]
    x=s1.count(c)
    sx1= (n//2-x)+sol(s2,n//2,chr(ord(c) + 1))
    x=s2.count(c)
    sx2= (n//2-x)+sol(s1,n//2,chr(ord(c) + 1))
    return min(sx1,sx2)
            
t=int(input())
while t>0:
    n=int(input())
    l=[i for i in input()]
    print(sol(l,n,"a"))
    t-=1