import math, sys
from collections import defaultdict, Counter, deque

INF = float('inf')
MOD = 1000000007

def gcd(a, b):
	while b:
		a, b = b, a%b
	return a

def isPrime(n):
	if (n <= 1): 
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i 
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))


def getcost(l, r, ch, s):
	cnt = 0
	for i in range(l, r + 1):
		if s[i] != chr(ch):
			cnt += 1
	# print(s[l:r + 1], cnt, chr(ch))
	return cnt

def good(l, r, s, ch):
	
	if l >= r:
		if s[l] == chr(ch): 
			return 0 
		else: 
			return 1 

	m = (l + r) // 2

	left = getcost(l, m, ch, s) + good(m + 1, r, s, ch + 1)
	right = getcost(m + 1, r, ch, s) + good(l, m, s, ch + 1)
	
	return min(left, right)

def main():
	n = int(input())
	s = input()
	ch = 97 
	print(good(0, n - 1, s, ch))

if __name__ == "__main__":
	t = int(input())
	# t = 1
	for _ in range(t):
		main()