def ss(s,c):
    n = len(s)
    if n == 1:
        if s[0]==c:
            return 0
        return 1
    c1 = n//2-s[0:n//2].count(c)
    c2 = n//2-s[n//2:n].count(c)
    x = c1 + ss(s[n//2:],chr(ord(c)+1))
    y = c2 + ss(s[0:n//2],chr(ord(c)+1))
    return min(x,y)

for _ in range(int(input())):
    n = int(input())
    s = input()
    m = ss(s,'a')
    print(m)