
    



def isGood(s,c):
    if len(s) == 1:
        if s == c:
            return 0
        else:
            return 1
    n = len(s)
    left = s[:n//2]
    right = s[n//2:]
    c1 = 0
    c2 = 0
    for i in left:
        if i != c:
            c1 += 1
    for i in right:
        if i != c:
            c2 += 1
    return min(c1+isGood(right, chr(ord(c)+1)), c2+isGood(left, chr(ord(c)+1)))





for tc in range(int(input())):
    n = int(input())
    s = input()
    print(isGood(s,'a'))
    