def num():
    return int(input())
def line():
    return map(int, input().split())
def ans(lst):
    return ' '.join(map(str,lst))
from itertools import repeat
from string import ascii_lowercase as alph

def q(c,i):
    l = len(c)
    if l==1:
        return int(c[0]!=alph[i])
    p1 = sum(x!=alph[i] for x in c[:l//2])
    p2 = sum(x!=alph[i] for x in c[l//2:])
    return min(p1+q(c[l//2:],i+1),p2+q(c[:l//2],i+1))

t = num()
for _ in repeat(None,t):
    n = num()
    s = list(input())
    print(q(s,0))

