def calc(s,c):
    return len(s)-s.count(c)
def ans(s,c):
    if len(s)==1:
        if s==c:
            return 0
        else:
            return 1
    return min(calc(s[:len(s)//2],c)+ans(s[len(s)//2:],chr(ord(c)+1)),calc(s[len(s)//2:],c)+ans(s[:len(s)//2],chr(ord(c)+1)))   
t=int(input())
for i in range(t):
            n=int(input())
            s=input()
            print(ans(s,'a'))
                   