
def dfs(arr, c):
  size = len(arr)
  if size == 1:
    if arr[0] == c:
      return 0
    return 1
  pr = 0
  po = 0

  mid = size//2
  for i in xrange(size):
    if arr[i] == c:
      if i < mid:
        pr += 1
      else:
        po += 1
  nex = chr(ord(c)+1)
  x1 = size//2 - po + dfs(arr[:mid], nex)
  x2 = size//2 + pr + dfs(arr[mid:], nex)
  return min(x1, x2)
  
for _ in xrange(int(raw_input())):
  size=int(raw_input())
  word=raw_input()
  print dfs(word,'a')