
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;


import java.util.*;

public class a {
	static long mod = 1000000007L;

	 public static void main(String[] args) throws Exception {
	        in = new BufferedReader(new InputStreamReader(System.in));
	        out = new PrintWriter(System.out);
	        sc = new FastScanner(in);
	       HashMap<Integer , HashMap<Integer , ArrayList<Integer>>> map = new HashMap<>();
	       int t =sc.nextInt();
	       while(t-->0) {
	    	  int n = sc.nextInt();
	    	  String a = sc.nextToken();
	    	  if(n==1) {
	    		  System.out.println(1);
	    		  continue;
	    	  }
	    	  int left =  0;
	 		 int right = 0 ;
	    	  char l ='a';
	 		 char r = 'a';
	 		 for(int i =0 ;i < a.length()/2 ;i++) {
	 			 if(l==a.charAt(i))left++;
	 		 }
	 		 for(int i = a.length()/2 ;i < a.length() ;i++) {
	 			 if(r==a.charAt(i))right++;
	 		 }
	 		 left = a.length()/2 - left;
	 		 right = a.length()/2 - right;
		    
	    	
	       System.out.println(Math.min( left + good('b',a.substring(a.length()/2)),right + good('b',a.substring(0 ,a.length()/2)))  );
	       
	       
	       }
	        out.flush();    
	    }
	 public static int max(String a , int lo , int hi , char ch ) {
		 int [] freq = new int[26];
		 int max = 0 ;
		 for(int i =lo ; i<hi;i++) {
			 freq[a.charAt(i)-'a']++;
			 max = Math.max(max, freq[a.charAt(i)-'a']);
		 }
		 return freq[ch-'a'];
	 }
	 public static int good( char ch, String a) {
		 if(a.length()<=1) {
			 if(a.charAt(0)==ch) {
				 return 0;
			 }return 1;
		 }
		 int left = max(a , 0 , a.length()/2 , ch);
		 int right = max(a , a.length()/2 , a.length(),ch) ;
		
		 left = a.length()/2 - left;
		 right = a.length()/2 - right;
		 
		 
		 String c = a.substring(a.length()/2);
		String d = a.substring(0 ,a.length()/2);
		 left += good((char)(ch+1) , c) ;
		 right += good((char)(ch+1), d);
		 return Math.min(left ,right );
	 }
	 
	 
	 
	 static class pair {
		 int ver ;
		 int val;
	 }
	 
	static int[] par;
	static int[] rank;

	static void build(int n) {
		par = new int[n + 1];
		rank = new int[n + 1];
		for (int i = 0; i < n; i++)
			par[i] = i;
	}

	static int find(int u) {
		if (u == par[u])
			return u;
		int v = find(par[u]);
		par[u] = v;
		return v;
	}

	static void union(int u, int v) {
		u = par[u];
		v = par[v];

		if (rank[u] > rank[v]) {
			par[v] = u;
		} else {
			par[u] = v;
			if (rank[u] == rank[v]) {
				rank[v]++;
			}
		}
	}




	public static TreeMap<Integer, TreeSet<Integer>> directed(int n, int m) throws Exception {
		TreeMap<Integer, TreeSet<Integer>> map = new TreeMap<>();
		for (int i = 0; i < n; i++)
			map.put(i, new TreeSet<Integer>());
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt() - 1;
			int b = i;
			map.get(b).add(a);
		}
		return map;
	}

	public static long[] input(int n) throws Exception {

		long[] arr = new long[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextLong();
		}
		return arr;
	}

	public static long[][] input(int n, int m) throws Exception {

		long[][] arr = new long[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {

				arr[i][j] = sc.nextInt();
			}
		}
		return arr;
	}

	static BufferedReader in;
	static FastScanner sc;
	static PrintWriter out;

	static class FastScanner {
		BufferedReader in;
		StringTokenizer st;

		public FastScanner(BufferedReader in) {
			this.in = in;
		}

		public String nextToken() throws Exception {
			while (st == null || !st.hasMoreTokens()) {
				st = new StringTokenizer(in.readLine());
			}
			return st.nextToken();
		}

		public int nextInt() throws Exception {
			return Integer.parseInt(nextToken());
		}

		public long nextLong() throws Exception {
			return Long.parseLong(nextToken());
		}

		public double nextDouble() throws Exception {
			return Double.parseDouble(nextToken());
		}
	}
}