def f(s, ch = 'a'):
    l = len(s)
    if l == 1:
        return 0 if s == ch else 1
    char = chr(ord(ch)+1)
 
    return min(f(s[:l//2], char) + sum(map(lambda x: 0 if x == ch else 1, s[l//2:])),
               f(s[l//2:], char) + sum(map(lambda x: 0 if x == ch else 1, s[:l//2])))

for item in range(int(input())):
    n = int(input())
    s = input()
    print(f(s))