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()))


#Recursive
def solve():
	ans = ""
	for _ in range(int(input())):
		n = int(input()); s = input()
		def getCost(l, r, ch):
		    return(r-l - s[l:r].count(chr(ch)))
		def getMin(l, r, ch):
		    if l+1 == r:
		        return([0, 1][chr(ch) != s[l]])
		    return(min(getCost(l, (l+r)//2, ch)+getMin((l+r)//2, r, ch+1), getCost((l+r)//2, r, ch)+getMin(l, (l+r)//2, ch+1)))
		ans += str(getMin(0, n, 97))+"\n"
	print(ans)



	





		

if __name__ == "__main__":
	solve()