import java.util.*;


import java.awt.Point;
import java.io.*;
import java.math.BigInteger;
public class Solutions {
	 
//	static ArrayList<ArrayList<Integer>>list=new ArrayList<ArrayList<Integer>>();
	static FastScanner scr=new FastScanner();
	static PrintStream out=new PrintStream(System.out);
	public static void main(String []args) {
		int t=scr.nextInt();
		while(t-->0) {
			solve();
		}
	}
	static boolean prime[]=new boolean[2000+1];
	static void solve() {
	  	int n=scr.nextInt();
	  	String s=scr.next();
	  	out.println(get(s,0,n-1,'a'));
	}
	static int get(String s,int low,int high,char c) {
		if(high-low==0) {
			return (s.charAt(low)==c)?0:1;
		}
		int cnt1=0;
		int cnt2=0;
		int mid=(low+high)>>1;
		for(int i=0;i<=mid;i++) {
			if(s.charAt(i)!=c) cnt1++;
		}
		for(int i=mid+1;i<=high;i++) {
			if(s.charAt(i)!=c) {
				cnt2++;
			}
		}
		cnt1+=get(s,mid+1,high,(char)(c+1));
		cnt2+=get(s,low,mid,(char)(c+1));
		return Math.min(cnt1,cnt2);
	}
	static boolean isPalindrome(String s,int low,int high) {
		
		for(int i=low,j=high;i<j;i++,j--) {
			if(s.charAt(i)!=s.charAt(j)) {
				return false;
			}
		}
		return true;
	}
	static boolean isPrime(int n) {
		for(int i=2;i*i<=n;i++) {
			if(n%i==0) {
				return false;
			}
		}
		return true;
	}
	static void swap(int a[],int i,int j) {
		int temp=a[i];a[i]=a[j];
		a[j]=temp;
	}
	static long modPow(long base,long exp,long mod) {
		if(exp==0) {
			return 1;
		}
		if(exp%2==0) {
			long res=(modPow(base,exp/2,mod));
			return (res*res)%mod;
		}
		return (base*modPow(base,exp-1,mod))%mod;
	}
	static long gcd(long a,long b) {
		if(b==0) {
			return a;
		}
		return gcd(b,a%b);
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int[] sort(int a[]) {
			Arrays.sort(a);
			return a;
		}
		int []reverse(int a[]){
			int b[]=new int[a.length];
			int index=0;
			for(int i=a.length-1;i>=0;i--) {
				b[index]=a[i];
			}
			return b;
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readLongArray(int n) {
			long  [] a=new long  [n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
	static int MAX=Integer.MAX_VALUE;
	static int MIN=Integer.MIN_VALUE;
}class triplet{
	int x;
	int y;
	int z;
	triplet(int fisrt,int second,int third){
		this.x=fisrt;
		this.y=second;
		this.z=third;
	}
}
class pair{
	int x=0;
	int y=0;
	pair(int first,int second){
		this.x=first;
		this.y=second;
	}
}