def calc(s, c):
    cnt = 0
    for i in s:
        if i != c:
            cnt += 1
    return cnt

def getAns(s, c):
    if len(s) == 1:
        if s[0] == c:
            return 0
        else:
            return 1
    else:
        mid = len(s)>>1
        left = calc(s[:mid], c) + getAns(s[mid:], chr(ord(c) + 1))
        right = getAns(s[:mid], chr(ord(c) + 1)) + calc(s[mid:], c)
        return min(left, right)

for t in range(int(input())):
    n = int(input())
    s = input()
    ans = getAns(s, 'a')
    print(ans)