def f(s,ch):
    if len(s)==1:return 0 if s[0]==ch else 1
    n=len(s);a=s[0:n//2];b=s[n//2:n]
    cntA=a.count(ch);cntB=b.count(ch)
    ch=chr(ord(ch)+1)
    return min(len(a)-cntA+f(b,ch),len(b)-cntB+f(a,ch))
for _ in range(int(input())):
    n = int(input())
    s = input()
    print(f(s,'a'))