import sys


#def solve(a,b,c,d):
def solve(s):
    #a = [c for c in s]

    def min_moves(s,c):
        if len(s) == 1:
            return 0 if s[0] == c else 1
        else: #len > 1:
           h = len(s)//2
           nc_1st = sum([1 if s[i] == c else 0 for i in range(h)])
           nc_2nd = sum([1 if s[i] == c else 0 for i in range(h,2*h)])
           if nc_1st < nc_2nd:
               # convert second to c
               return (h-nc_2nd) + min_moves(s[:h],chr(ord(c)+1))
           elif nc_1st == nc_2nd:
               # convert second to c
               return min( (h-nc_2nd) + min_moves(s[:h],chr(ord(c)+1)), \
                           (h-nc_1st) + min_moves(s[h:],chr(ord(c)+1)) )
           else:
               # convert first to c
               return (h-nc_1st) + min_moves(s[h:],chr(ord(c)+1))
               

    mn = float('inf')
    #for c0 in 'abcdefghijklmnopqrstuvwxyz':
    for c0 in 'a':
        count_c0 = min_moves(s,c0)
        #if count_c0 < mn:
            #print(c0,count_c0)
        mn = min(mn, count_c0)
       
    print(mn)


if __name__ == '__main__':
    IN = [x.strip() for x in sys.stdin.readlines()]

    T = int(IN[0])
    cur = 1
    for ti in range(T):
        n = int(IN[cur])
        #a = [int(x) for x in IN[cur].split(' ')]
        s = IN[cur+1]
        #= [int(x) for x in IN[cur+1].split(' ')]
        solve(s)
        #print(' '.join([str(a) for a in result]))
        cur += 2

