t = int(input())

def compt(s, lettre):
    n= len(s)
    if n==1:
        if s[0]==lettre:
            return 0
        else:
            return 1
    else:
        c1 = s[:n//2].count(lettre)
        c2 = s[n//2:].count(lettre)
        return min(n//2-c1+compt(s[n//2:], chr(ord(lettre)+1)), n//2-c2+compt(s[:n//2], chr(ord(lettre)+1)))
        
for case in range(t):
    n = int(input())
    t = input()
    print(compt(t, 'a'))