
from collections import Counter


def cal(l, r, i):
    if l == r:
        if s[l] == i:
            return 0
        else:
            return 1
    m = (l+r)//2
    cnt1 = Counter(s[l:m+1])
    cnt2 = Counter(s[m+1:r+1])
    l1 = (r-l+1)//2 - cnt1.get(i, 0) + cal(m+1, r, i+1)
    l2 = (r-l+1)//2 - cnt2.get(i, 0) + cal(l, m, i+1)
    return min(l1, l2)

    




x = int(input())
for i in range(x):
    n = int(input())
    s = input()
    s = [ord(i)-ord('a') for i in s]
    print(cal(0, len(s)-1, 0))

    