
def think(A, mid, s):
   if len(s)==1:
      if s[0]==A: return 0
      else : return 1

   f_half = think(A+1, mid//2, s[:mid])
   f_half += (mid - s[mid:].count(A))
   s_half = think(A+1, mid//2, s[mid:])
   s_half += (mid - s[:mid].count(A))
   return min(f_half, s_half)
 

for _ in range(int(input())):
   n = input()
   s = list(map(ord, str(input())))
   A = 97
   mid = len(s)//2
   moves = think(A, mid, s)
   print(moves)
   
