import java.io.*;
import java.util.*;

public class D {
	
	public static int compare(String str,int x,int l,int r) {
		int cnt=0;
		x=(char)x;
		while(l<=r) {
			if(str.charAt(l)!=x) {
				cnt++;
			}
			l++;
		}
		return cnt;
	}
	
	public static int func(String string,int s,int e,int c,int what) {
		if(s==e) {
			if(string.charAt(s)==(char)c)
				return 0;
			else
				return 1;
		}
		else if(what==0) {
			return compare(string, c, s, e);
		}
		else {
			int mid=(s+e)/2;
			return Math.min(func(string, s, mid, c, 0)+func(string, mid+1, e, c+1, 1),func(string, s, mid, c+1, 1)+func(string, mid+1, e, c, 0));
		}
	}
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		FastOutput fo = new FastOutput();
		int testcases = fs.nextInt();
		for (int tt = 0; tt < testcases; tt++) {
			//main code
			int n=fs.nextInt();
			String str=fs.next();
			if(n==1) {
				if(str.charAt(0)=='a') {
					fo.println(0);
				}
				else {
					fo.println(1);
				}
				continue;
			}
			int x=Math.min(func(str,0,n/2-1,97,0)+func(str,n/2,n-1,98,1),func(str,0,n/2-1,98,1)+func(str,n/2,n-1,97,0));
			fo.println(x);
		}
		/*
		 * a-string->aaaabbcd or bbcdaaaa or aaaacdbb or cdbbaaaa or aaaabbdc or bbdcaaaa or dcbbaaaa
		 * a->97
		 * b->98
		 * c->99..........
		 * 0->whole part in same
		 * 1->that part will be divided by two equal half
		 */
	}

	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 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 nextLong() {
			return Long.parseLong(next());
		}
	}

	static class FastOutput {
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

		void print(String str) {
			try {
				bw.write(str);
				bw.flush();
			} catch (IOException e) {
			}
		}

		void print(int num) {
			try {
				bw.write((num + ""));
				bw.flush();
			} catch (IOException e) {
			}
		}

		void println(String str) {
			try {
				bw.write(str + '\n');
				bw.flush();
			} catch (IOException e) {
			}
		}

		void println(int num) {
			try {
				bw.write(num + "" + '\n');
				bw.flush();
			} catch (IOException e) {
			}
		}
	}
}
