def goodstring(s,alpha):
    n=len(s)
    if n==1:
        if s==alpha:
            return 0
        else:
            return 1
    
    mid=(n//2)

    t1 = goodstring(s[:mid],chr(ord(alpha)+1))
    t2 = goodstring(s[mid:],chr(ord(alpha)+1))
    t1dash = 0
    t2dash = 0
    for i in range(n):
        if i<mid and s[i]!=alpha:
            t2dash+=1
        if i>=mid and s[i]!=alpha:
            t1dash+=1
    return min(t1+t1dash,t2+t2dash)

for _ in range(int(input())):
    n=int(input())
    s=input()
    print(goodstring(s,'a'))