
def solve(S, ch = ord('a')) :
  if len(S) == 1 : return int(S != chr(ch))
  costL, costR = 0, 0
  for i in range(len(S)//2) :
    if S[i] != chr(ch) : costL += 1
  for i in range(len(S)//2, len(S)) :
    if S[i] != chr(ch) : costR += 1

  solveL, solveR = solve(S[:len(S)//2], ch+1), solve(S[len(S)//2:], ch+1)
  return min(costL + solveR, costR + solveL)

T = input()
for t in range(T) :
  N = input()
  S = raw_input()

  print solve(S)