def solve(s,c):
    if (len(s) == 1):
        return (1 - s.count(c))
    return min((len(s)//2) - s[len(s)//2:len(s)].count(c) + solve(s[0:len(s)//2],chr(ord(c)+1)),
               (len(s)//2) - s[0:len(s)//2].count(c) + solve(s[len(s)//2:len(s)],chr(ord(c)+1)))

t = int(input().split()[0])
for case in range(t):
    n = int(input().split()[0])
    s = input().split()[0]
    print(solve(s,'a'))
