# itne me hi thakk gaye?
from collections import defaultdict
from sys import setrecursionlimit, stdin, stdout
setrecursionlimit(10**5)
el = list('abcdefghijklmnopqrstuvwxyz')
for _ in range(int(stdin.readline().strip())):
    n = int(stdin.readline().strip())
    s = list(stdin.readline().strip())
    def getans(s, char):
        n = len(s)
        if n == 1:
            if s[0] == el[char]:
                return 0
            else:
                return 1
        tot = n//2
        sl = s[:tot]
        c1 = tot - sl.count(el[char])
        sr = s[tot:]
        c2 = tot - sr.count(el[char])
        # print(s, el[char], sl, sr)
        return min(c1 + getans(sr, char+1), c2 + getans(sl, char+1))
    print(getans(s, 0))