import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
# input = lambda: sys.stdin.buffer.readline().rstrip()

def a(w,l,c):
	if len(w)==1:
		if w[0]==c:
			return 0
		else:
			return 1
	else:
		e=chr(ord(c)+1)
		return min(l-w[:l].count(c)+a(w[l:],l//2,e),l-w[l:].count(c)+a(w[:l],l//2,e))
for _ in range(int(input())):
	q=int(input())
	w=input()
	print(a(w,q//2,'a'))