import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int t = sc.nextInt();
    while (t --> 0) {
      int n = sc.nextInt();
      String s = sc.next();
      int ans = f('a', s);
      System.out.println(ans);
    }
  }
  public static int f(char c, String s) {
    if (s.length() == 1) {
      return s.charAt(0)==c?0:1;
    } else {
      return Math.min(f((char)(c+1),s.substring(0, s.length()/2)) + toc(c,s.substring(s.length()/2)), f((char)(c+1), s.substring(s.length()/2)) + toc(c,s.substring(0,s.length()/2)));
    }
  }
  public static int toc(char c, String s) {
    char ch[] = s.toCharArray();
    int ans = 0;
    for (int i = 0; i < s.length(); i++) {
      if(ch[i] != c)ans++;
    }
    return ans;
  }
}