import java.io.*;

import java.util.*;



public class problemA 
{
   public static void main (String[] args) throws IOException
   {
   
      BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer token = new StringTokenizer(input.readLine());
      int maxCount = Integer.parseInt(token.nextToken());
      for(int b = 0; b < maxCount; b++)
      {
         token = new StringTokenizer(input.readLine());
         int arrayLength = Integer.parseInt(token.nextToken());
         String s = input.readLine();
         System.out.println(findMoves(s, "a"));
      }
   }
   public static int findMoves(String total, String letter)
   {
      if(total.length() == 1)
      {
         if(total.equals(letter))
            return 0;
         else
            return 1;
      }
      String letters = "abcdefghijklmnopqrstuvwxyz";
      int half = (int)(total.length() / 2);
      String firstHalf = total.substring(0, half);
      String secondHalf = total.substring(half);
      int firstHalfCount = 0;
      int secondHalfCount = 0;
      for(int x = 0; x < half; x++)
      {
         if(!Character.toString(firstHalf.charAt(x)).equals(letter))
            firstHalfCount++;
         if(!Character.toString(secondHalf.charAt(x)).equals(letter))
            secondHalfCount++;
      }
      int firstOption = firstHalfCount + findMoves(secondHalf, Character.toString(letters.charAt(letters.indexOf(letter) + 1)));
      int secondOption = secondHalfCount + findMoves(firstHalf, Character.toString(letters.charAt(letters.indexOf(letter) + 1)));
      return Math.min(firstOption, secondOption);
   }
}