import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


#Iterative
def solve():
	ans = ""
	for _ in range(int(input())):
		n = int(input()); s = input()
		arr = []; min_cost = float("inf")
		def getCost(l, r, ch):
			return(r-l - s[l:r].count(chr(ch)))
		arr = [(0, n, 97, 0)]
		while arr:
			tem = []
			for i in arr:
				l, r, ch, cost = i
				if l+1 == r:
					min_cost = min(min_cost, cost+(s[l] != chr(ch)))
				else:
					tem.extend([(l, (l+r)//2, ch+1, cost+getCost((l+r)//2, r, ch)), 
								((l+r)//2, r, ch+1, cost+getCost(l, (l+r)//2, ch))])
			arr = tem
		ans += str(min_cost)+"\n"
	print(ans)



	





		

if __name__ == "__main__":
	solve()
	# arr = [10,20,30,40,50]
	# print([func(1, i)+1 for i in arr])
	# print(func(2, 11))








# 0000101111