def call(n,ch,s):
    if n<=0:
        return 0
    if n==1:
        if s[0]!=ch:
            return 1
        return 0
    c1,c2=0,0
    for i in range(0,n//2):
        if s[i]!=ch:
            c1=c1+1
    c1+=call(n//2,chr(ord(ch)+1),s[n//2:])
    for j in range(n//2,n):
        if s[j]!=ch:
            c2+=1
    c2+=call(n//2,chr(ord(ch)+1),s[:n//2])
    if c1==0 and c2==0:
        return 0
    return min(c1,c2)
       



t=int(input())
while(t>0):
    t=t-1
    n=int(input())
    s=input()
    print(call(n,'a',s))
