import sys


# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

# sys.setrecursionlimit = 10**5

input = sys.stdin.readline
def counter(l,r,ch):
    count=0
    for i in range(l, r+1):
        if s[i] != ch:
            count+=1
    return count 

def calc(l, r, code):
    letter = chr(97 + code)
    while l >= r:
        return int(s[l] != letter)
    mid = (l+r)//2

    return min(counter(l, mid, letter) + calc(mid+1, r, code + 1),
             counter(mid+1, r, letter) + calc(l, mid, code+1))


t = int(input())

while t:
    t -= 1

    n = int(input())
    s = input().strip()

    ans = calc(0, n-1, 0)
    print(ans)

    





