def func(s,i):
    l = len(s)
    if l==1:
        if s[0]==tab[i]:
            return 0
        else:
            return 1
    aa= min(func(s[:l//2],i+1) + l//2 - s[l//2:].count(tab[i]) , l//2 - s[:l//2].count(tab[i]) + func(s[l//2:],i+1))
    return aa
tab='abcdefghijklmnopqrstuvwxyz'
for _ in range(int(input())):
    n = int(input())
    s = list(input())
    i=0
    ans=func(s,i)
    print(ans)
