import math

def get_matches(string, letter, start, end):
  count = 0
  for i in range(start, end + 1):
    if(string[i] == letter):
      count += 1
  return count

def make_good_string(string, letter_index, start, end):
  letter = LETTERS[letter_index]
  if(start == end):
    if(string[start] == letter):
      return 0
    return 1

  middle = math.floor((start + end) / 2)
  start1 = start
  end1 = middle
  start2 = middle + 1
  end2 = end

  stringACount = get_matches(string, letter, start1, end1)
  stringBCount = get_matches(string, letter, start2, end2)
  costA = (end1 - start1 + 1) - stringACount
  costB = (end2 - start2 + 1) - stringBCount
  

  op1 = costA + make_good_string(string, letter_index + 1, start2, end2)
  op2 = costB + make_good_string(string, letter_index + 1, start1, end1)
  
  if(op1 < op2):
    return op1
  else:
    return op2

LETTERS = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

queries = int(input())

for i in range(queries):
  length = int(input())
  string = input()
  result = make_good_string(list(string), 0, 0, length - 1)
  print(result)
