li=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q']
def yooman(x):
    sum=0
    while(x!=0):
        x=x//2
        sum+=1
    return sum-1
def stri(s,x,sumi,j):
    if x>1:
        a1=s[:x//2]
        a2=s[x//2:]
        if a1.count(li[j])>=a2.count(li[j]):
            s1=a2
            sumi+=x//2-a1.count(li[j])
            j+=1
            x=x//2
        else:
            s1=a1
            sumi+=x//2-a2.count(li[j])
            j+=1
            x=x//2
        return stri(s1,x,sumi,j)
    else:
        if s!=li[j]:
            sumi+=1
        return sumi 
a=int(input())
for i in range(a):
    x=int(input())
    s=input()
    sumi=0
    j=0
    print(stri(s,x,sumi,j))