import string
x = 'abcdefghijklmnopqrstuvwxyz'
 
def func(s,n,i):
    if len(s)==1:
        if s==x[i]:
            return 0
        else:
            return 1
 
    count1 = s[:n//2].count(x[i])
    count2 = s[n//2:].count(x[i])
    return min((func(s[:n//2],n//2,i+1) + (n//2-(count2))),(func(s[n//2:],n//2,i+1) + (n//2-(count1))))
    
t = int(input())
for _ in range(t):
    n = int(input())
    s = input()
    print(func(s,n,0))