def f(x,z):
    if(len(x)==0):
        return 0
    if(len(x)==1):
        return int(x!=z)
    m = len(x)//2
    L = x[:m]
    R = x[m:]
    a = m - L.count(z) + f(R, chr(ord(z)+1))
    b = m - R.count(z) + f(L, chr(ord(z)+1))
    return min(a, b)
t = int(input())
while t:
    s = int(input())
    word = input()
    print (f(word, 'a'))
    t-=1