from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from functools import lru_cache
from heapq import heappush, heappop
import math

setrecursionlimit(100000)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

tonum = lambda c: ord(c) - 97
tochr = lambda num: chr(num + 97)

def solv(s, i, j, need):
	if i > j: return 0
	if i == j: return 0 if s[i] == tochr(need) else 1
	mid = (i + j)//2
	cnt1, cnt2 = 0, 0
	cneed = tochr(need)
	for x in range(i, mid+1):
		if s[x] != cneed: cnt1 += 1
	for x in range(mid+1, j+1):
		if s[x] != cneed: cnt2 += 1
	# print(f"i, j, need, mid = {i, j, cneed, mid}. fix_a = {cnt1}, fix_b = {cnt2}")
	if cnt1 < cnt2:
		return cnt1 + solv(s, mid+1, j, need+1)
	elif cnt2 > cnt1:
		return cnt2 + solv(s, i, mid, need+1)
	else:
		return min(cnt1+solv(s,mid+1,j,need+1), cnt2+solv(s,i,mid,need+1))

def main():
	T = int(rl())
	for _ in range(T):
		n = int(rl())
		s = rll()[0]
		x = solv(s, 0, len(s)-1, 0)
		print(x)
	stdout.close()

if __name__ == "__main__":
	main()