
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.Random;

public class Main {

	public Main() throws FileNotFoundException {
//
//		File file = Paths.get("input.txt").toFile();
//		if (file.exists()) {
//			System.setIn(new FileInputStream(file));
//		}
//		// long t = System.currentTimeMillis();

		InputReader reader = new InputReader();

		int tt = reader.nextInt();

		Random r = new Random();
		for (int t = 0; t < tt; t++) {

			
			int n=reader.nextInt();
			
			char[] a=reader.nextString().toCharArray();
			
			
			int num=check(a,n,0,a.length-1,'a');
			
			System.out.println(num);

		}
	}
	
	private int check(char[] a,int n,int from,int to,char c) {
		if(from==to) {
			if(a[from]==c) {
				return 0;
			}
			return 1;
		}
		
		int half=from+(to-from+1)/2-1;
		int num=(to-from+1)/2;
//		
//		if(to-from==1) {
//			half=from;
//			num=1;
//		}
		
		
		//from - half,half+1 - to;
		int c1=0;
		int c2=0;
		for(int i=from;i<=half;i++) {
			if(a[i]==c) {
				c1++;
			}
		}
		for(int i=half+1;i<=to;i++) {
			if(a[i]==c) {
				c2++;
			}
		}
		
		int ans=0;
		
		if(c1==c2) {
			int num1=num-c1+check(a,n,half+1,to,(char)(c+1));
			int num2=num-c2+check(a,n,from,half,(char)(c+1));	
			
			return Math.min(num1, num2);
		}else if(c1>c2) {
			//first half
			ans+=num-c1;
			ans+=check(a,n,half+1,to,(char)(c+1));	
		}else {
			//second half
			ans+=num-c2;
			ans+=check(a,n,from,half,(char)(c+1));	
		}
		
		//0-1
		return ans;
	}

	static class InputReader {
		private byte[] buf = new byte[16384];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) {
				arr[i] = nextInt();
			}
			return arr;
		}

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

		private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

	}

	public static void main(String[] args) throws FileNotFoundException {
		new Main();
	}

}
