def f(s, c):
    if len(s) == 1:
        if s[0] == c:
            return 0
        else:
            return 1
    q = s[0:len(s) // 2].count(c)
    w = s[len(s)//2:].count(c)
    e = len(s) // 2 - q + f(s[len(s) // 2 :], chr(ord(c) + 1))
    ee = len(s) // 2 - w + f(s[0:len(s) // 2], chr(ord(c) + 1))
    return min(e, ee)


t = int(input())

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