def f(l, r, c, s):
    mid = (l+r)//2
    if(r-l == 1):
        if(s[l] != c):
            return("1")
        else:
            return("0")
    else:
        countl = (r-l)//2 - int(s[l:mid].count(c)) + int(f(mid, r, str(chr(ord(c)+1)), s))
        countr = (r-l)//2 - int(s[mid:r].count(c)) + int(f(l, mid, str(chr(ord(c)+1)), s))
        return(min(countl, countr))
for _ in range(int(input())):
    n = int(input())
    s = input()
    print(f(0, n, 'a', s))