# coding: utf-8

alphabet = "abcdefghijklmnopqrstuvwxyz"
t = int(input())
responses = []

def good_string(i, string, n):
  if i == len(alphabet):
    i = 0

  c = alphabet[i]

  if n == 1:
    return 1 if string != c else 0
  
  if n == 2:
    left, right = string
    c_plus_1 = (i + 1) if (i < len(alphabet) - 1) else 0
    c_next = alphabet[c_plus_1]

    if left == right:
      if left in [c, c_next]:
        return 1
      return 2
    else:
      if left == c:
        return 0 if right == c_next else 1
      if right == c:
        return 0 if left == c_next else 1
      if left == c_next or right == c_next:
        return 1
      return 2

  h = n // 2
  left = string[:h]
  right = string[h:]

  if left == (h * c):
    return good_string(i+1, right, h)
  else:
    if right == (h * c):
      return good_string(i+1, left, h)
    else:
      left_moves_to_c = right_moves_to_c = 0
      for j in range(h):
        left_moves_to_c += 0 if left[j] == c else 1
        right_moves_to_c += 0 if right[j] == c else 1
      
      if left_moves_to_c > right_moves_to_c:
        return right_moves_to_c + good_string(i+1, left, h)
      elif left_moves_to_c < right_moves_to_c:
        return left_moves_to_c + good_string(i+1, right, h)
      else:
        return left_moves_to_c + min(good_string(i+1, left, h), good_string(i+1, right, h))

for _ in range(t):
  n = int(input())
  s = input()
  responses.append(good_string(0, s, n))
  if _ == 370:
    print("\t%s => %s" % (s, responses[-1]))
  
for response in responses:
  print(response)