from sys import stdout,stdin,setrecursionlimit
setrecursionlimit(100000)
input=stdin.readline
def minchange(a,d):
    b=c=0
    if len(a)==1:
        if a[0]==chr(d):
            return 0
        else:
            return 1
    n=len(a)
    for i in range(0,n//2):
        if a[i]!=chr(d):
            b+=1
    for i in range(n//2,n):
        if a[i]!=chr(d):
            c+=1
    return (min(c+minchange(a[:n//2],d+1),b+minchange(a[n//2:n],d+1)))
def solve():
    n=int(input())
    a=input().strip()
    print(minchange(a,97))
def main():
    for t in range(int(input())):
        solve()
if __name__=="__main__":
    main()