import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.Set;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
//import com.google.common.collect.HashMultiset; 
//import com.google.common.collect.Multiset;


public class code6 {

	static int ans = 0;
	static int[] arr;
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
		public int[] nextIntArray(int n) {
	    	int[] a = new int[n];
	    	for(int i = 0; i < n; i ++)
	    		a[i] = nextInt();
	    	return a;
	    }
	    
	    public long[] nextLongArray(int n) {
	    	long[] a = new long[n];
	    	for(int i = 0; i < n; i ++)
	    		a[i] = nextLong();
	    	return a;
	    }
	    
	    public double[] nextDoubleArray(int n) {
	    	double[] a = new double[n];
	    	for(int i = 0; i < n; i ++)
	    		a[i] = nextDouble();
	    	return a;
	    }
	}
	public static void main(String[] args) throws CloneNotSupportedException {
		// TODO Auto-generated method stub
		FastReader scn = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int t = scn.nextInt();
		//int p = t;
		while(t-->0) {
			int n = scn.nextInt();
			String str = scn.next();
			System.out.println(rec(str, 'a'));
		}
		
		out.flush();
	}
	
	public static int rec(String str, char a) {
		if(str.length() == 1) {
			if(str.charAt(0) == a)
				return 0;
			else
				return 1;
		}
		int n = str.length()/2;
		int c = 0;
		for(int i=0; i<n; i++) {
			if(str.charAt(i) != a)
				c++;
		}
		int ans1 = c+rec(str.substring(n), (char)(a+1));
		c = 0;
		for(int i=n; i<2*n; i++) {
			if(str.charAt(i) != a)
				c++;
		}
		int ans2 = c + rec(str.substring(0,n), (char)(a+1));
		return Math.min(ans1, ans2);
		
	}
	
	public static class stud{
		private int roll;
		String name;
	}
	
	public static void dfs(ArrayList<Integer>[] tree, int i, int l, int[] level) {
		level[i] = l;
		for(int j=0; j<tree[i].size(); j++) {
			dfs(tree, tree[i].get(j), l+1, level);
		}
	}
	public static void dfs(int i, boolean[] vis, int[] parent, int[] level, int a, int last) {
		if(i == -1)
			return;
		if(level[last]-level[i] == a) {
			if(!vis[i])
				ans++;
			vis[i] = true;
			last = i;
		}
		dfs(parent[i], vis, parent, level, a, last);
	}
	public static int[] PossibleKey(int[] arr) {
		int[] ans = new int[4];
		for(int i=0; i<4; i++)
			arr[i] = 1;
		int[] help = new int[4];
		int i = 0;
		int ch = 0;
		int cl = 0;
		for(i = 1; i<4; i++) {
			if(arr[i]>arr[i-1]) {
				for(int j=0; j<4; j++)
					help[j]++;
			}
			if(arr[i]<arr[i-1]) {
				for(int j=0; j<4; j++)
					help[j]--;
			}
			for(int j=0; j<4; j++) {
				if(help[j]+j<0 || help[j]+j>4)
					ans[j] = 0;
			}
		}
		return ans;
		
	}
	
//	public static int dfs(ArrayList<Integer>[] graph, boolean[] vis, int i) {
//		int s= 1;
//		vis[i] = true;
//		for(int j=0; j<graph[i].size(); j++) {
//			if(!vis[graph[i].get(j)])
//				s += dfs(graph, vis, graph[i].get(j));
//		}
//		if(s%2 == 0)
//			ans++;
//		return s;
//	}
	
  
	public static boolean check(int mid, int c, int[] arr, int k) {
		int ans = 0;
		for(int i=0; i<arr.length; i++) {
			if(c==0) {
				ans++;
				c = (c+1)%2;
			}else {
				if(arr[i]<=mid) {
					ans++;
					c = (c+1)%2;
				}
			}
		}
		return ans>=k;
	}
	public static long power(long x, long y, int p) 
    { 
        // Initialize result 
        long res = 1;      
         
        // Update x if it is more   
        // than or equal to p 
        x = x % p;  
  
       if (x == 0) return 0; // In case x is divisible by p;    
  
        while (y > 0) 
        { 
            // If y is odd, multiply x 
            // with result 
            if((y & 1)==1) 
                res = (res * x) % p; 
      
            // y must be even now 
            // y = y / 2 
            y = y >> 1;  
            x = (x * x) % p;  
        } 
        return res; 
    } 
	
	public static int[] nextG(int[] arr, int n) {
		int[] ans = new int[n];
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(0);
		for(int i=1; i<n; i++) {
			while(!stack.isEmpty() && arr[stack.peek()]<=arr[i])
				ans[stack.pop()] = i;
			stack.push(i);
		}
		while(!stack.isEmpty())
			ans[stack.pop()] = n;
		return ans;
	}
	public static int[] nextGRev(int[] arr, int n) {
		int[] ans = new int[n];
		Stack<Integer> stack = new Stack<Integer>();
		stack.push(n-1);
		for(int i=n-2; i>=0; i--) {
			while(!stack.isEmpty() && arr[stack.peek()]<=arr[i])
				ans[stack.pop()] = i;
			stack.push(i);
		}
		while(!stack.isEmpty())
			ans[stack.pop()] = -1;
		return ans;
	}
	
	public static class Pair {
		int i;
		int l;
		int r;
		long k;
		Pair(int x, int z, int b){
			i = x;
			//a = y;
			l = z;
			r = b;
		}
		public long compareTo(Pair p) {
			if(arr[this.i] == arr[p.i]) {
				long a = arr[this.l]+arr[this.r];
				long b = arr[p.l]+arr[p.r];
				return b-a;
			}
			return arr[this.i] - arr[p.i];
		}
	}
    
}

