def count_ch(st, n, ch):
    p = 0
    for i in range(n):
        if st[i] == ch:
            if i < n/2:
                p += 1
            else:
                p -= 1
    if p == 0:
        if ch == 'z':
            return 1
        return count_ch(st, n, chr(ord(ch)+1))
    elif p > 0:
        return 1
    else:
        return 2

def st_c(st, n, ch):
    if n == 1:
        if st == ch:
            return 0
        else:
            return 1
    if n == 2:
        if st[0] == ch:
            return st_c(st[1], 1, chr(ord(ch) + 1))
        elif st[1] == ch:
            return st_c(st[0], 1, chr(ord(ch) + 1))
        else:
            if chr(ord(ch)+1) == st[0] or chr(ord(ch)+1) == st[1]:
                return 1
            else:
                return 2
    f = s = 0
    s1 = s2 = str()
    for i in range(n):
        if i >= n / 2:
            s2 += st[i]
            if st[i] == ch:
                s += 1
        else:
            s1 += st[i]
            if st[i] == ch:
                f += 1
    if s == f:
        if count_ch(st, n, chr(ord(ch) + 1)) == 1:
            return n / 2 - s + st_c(s1, n // 2, chr(ord(ch) + 1))
        else:
            return n / 2 - f + st_c(s2, n // 2, chr(ord(ch) + 1))
    elif s > f:
        return n / 2 - s + st_c(s1, n//2, chr(ord(ch) + 1))
    else:
        return n / 2 - f + st_c(s2, n//2, chr(ord(ch) + 1))

for _ in range(int(input())):
    n = int(input())
    st = input()
    print(int(st_c(st, n, 'a')))

