def goodString(word, size, unique):
  if (size == 1):
    if(word != unique):
      return 1
    else:
      return 0

  uniqueTwo = chr(1 + ord(unique))
 
  mid = size // 2
  firstWord = word[:mid]
  lastWord = word[mid:]
  uniqueTwo = chr(1 + ord(unique))
 
  calculationOne = len(firstWord) - firstWord.count(unique) + goodString(lastWord, len(lastWord), uniqueTwo)
  calculationTwo = len(lastWord) - lastWord.count(unique) + goodString(firstWord, len(firstWord), uniqueTwo)
 
  if (calculationOne < calculationTwo):
      return calculationOne
  else:
      return calculationTwo
 
n = int(input())

for i in range(n):
   size = int(input())
   word = input()
   print(goodString(word, size, 'a'))
