def g(string,s):
    ans = 0
    for i in range(2):
        if string[i] != s[i]:
            ans = ans+1
    return(ans)
def h(string,s,l):
    c = 0
    for i in range(l):
        if string[i] != s:
            c = c+1
    return(c)
def f(string,s,n):
    if n == 1:
        if string == s:
            return(0)
        else:
            return(1)
    else:
        string1 = string[0:n//2]
        string2 = string[n//2:]
        y = h(string1,s,n//2)
        z = h(string2,s,n//2)
        c = chr(ord(s)+1)
        return(min(y+f(string2,c,n//2),z+f(string1,c,n//2)))
t = int(input())
while(t>0):
    t = t-1
    n = int(input())
    s = input()
    print(f(s,"a",n))