import sys

sys.setrecursionlimit(10**6)

# input = open('file.txt').readline


ANS = [1000000]

def rec(c , st , en , l ,  n , need , req ):

  # print(c , arr , st , en , l ,  n)
  nx = chr( ord(c) + 1 )


  if en - st == 1:

    if nx != req[st]:
      need += 1

    if need < ANS[0]:
      ANS[0] = need

    # ans.append(arr1)
    return


  need1 , need2 = need , need


  for i in range(st , (st+en)//2 ):
    # arr1[i] = nx

    if nx != req[i]:
      need1 += 1

  for i in range( (st+en)//2  , en ):
    # arr2[i] = nx

    if nx != req[i]:
      need2 += 1
  
  l += (en-st)//2

  if l > n:

    if need1 < ANS[0]:
      ANS[0] = need1
    elif need2 < ANS[0]:
      ANS[0] = need2 

    return
  else:
    rec( nx , (st+en)//2  , en , l ,  n , need1 , req )
    rec(  nx , st , (st+en)//2 , l ,  n , need2 , req )






def solve( req , n ):

  rec('`' , 0 , n , 0 , n , 0 , req )
  print(ANS[0])

for _ in range( int(input()) ):

  n = int(input())
  req = input()

  solve(req,n)
  ANS[0] = 1000000

