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):
    if len(s)==1:
        if alp[x]==s:
            return 0
        else:
            return 1
    else:
        l = len(s)
        req = alp[x]*(l//2)
        c1 = len([i for i in range(l//2) if s[:l//2][i]==req[i]])
        c2 = len([i for i in range(l//2) if s[l//2:][i]==req[i]])
        if c1>=c2:
            return ((l//2)-c1)+gt(s[l//2:],x+1)
        else:
            return ((l//2)-c2)+gt(s[:l//2],x+1)

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