import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(5*10**5)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return list(input().split())
def S(): return input()

def dfs(s, x):
    if len(s) == 1:
        return  0 if s == x else 1
    n = len(s) // 2
    s_first = s[:n]
    s_second = s[n:]
    nx = chr(ord('a') + (ord(x) - ord('a') + 1) % 26)

    ans_first = n - s_first.count(x) + dfs(s_second, nx)
    ans_second = n - s_second.count(x) + dfs(s_first, nx)
    return min(ans_first, ans_second)

def solve():
    n = II()
    s = S()
    return dfs(s, 'a')

def main():
    t = II()
    res = list()
    for _ in range(t):
        res.append(solve())
    for ans in res:
        print(ans)
    return 0

main()