alp =['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
def gt(s,x):
    #print(s,alp[x])
    if len(s)==2:
        if alp[x] in s and alp[x+1] in s:
            return 0
        elif alp[x] in s or alp[x+1] in s:
            return 1
        else:
            return 2
    if len(s)==1:
        if alp[x]==s:
            return 0
        else:
            return 1
    else:
        l = len(s)
        req = alp[x]*(l//2)+alp[x+1]*(l//2)
        c1 = len([i for i in range(l) if s[i]==req[i]])
        c2 = len([i for i in range(l) if s[::-1][i]==req[i]])
        if c1>=c2:
            y = len([i for i in range(l//2) if s[i]==req[i]])
            return ((l//2)-y)+gt(s[l//2:],x+1)
        elif c2>c1:
            y = len([i for i in range(l//2) if s[::-1][i]==req[i]])
            return ((l//2)-y)+gt(s[:l//2],x+1)

for _ in range(int(input())):
    n = int(input())
    s = input()
    print(gt(s,0))