def f(s,c):
    if len(s)==1:
        if s!=c:return 1
        else:return 0
    n = len(s)
    cnt1 = n/2 + f(s[:n/2],chr(ord(c)+1)) - s[n/2:].count(c)
    cnt2 = n/2 + f(s[n/2:],chr(ord(c)+1)) - s[:n/2].count(c)
    return min(cnt1,cnt2)
for _ in range(input()):
    n = input()
    s = raw_input()
    print f(s,'a')
