def read_list():
	return list(map(int,input().split(' ')))
def print_list(l):
	print(' '.join(map(str,l)))

# import heapq
# import bisect
# from collections import deque
# from collections import defaultdict
# import math

# f = open('test.py')
# def input():
# 	return f.readline().replace('\n','')

def count(c,start,end):
	res = 0
	for i in range(start,end):
		if s[i]!=c:
			res+=1
	return res

def match(c,start,end):
	if start+1 == end:
		if s[start]==c:
			return 0
		else:
			return 1

	l = (end-start)>>1
	return min(count(c,start,start+l)+match(chr(1+ord(c)),start+l,end), count(c,start+l,end)+match(chr(1+ord(c)),start,start+l))

N = int(input())
for _ in range(N):
	n = int(input())
	s = input().strip()
	print(match('a',0,n))

