def find(s,c):
    char = chr(97+c)
    if len(s) == 1:
        if s[0] == char:
            return 0
        else:
            return 1
    else:
        mid = len(s)//2
        cntL = len(s)//2 - s[:mid].count(char) + find(s[mid:],c+1)
        cntR = len(s)//2 - s[mid:].count(char) + find(s[:mid],c+1)
        return min(cntL,cntR)

for _ in range(int(input())):
    n = int(input())
    s = input().strip()
    print(find(s,0))