def freq(s, c):
  count = 0
  for i in s:
    if i == c:
      count += 1
  return count

def good(s, c):
  if(len(s) == 1):
    if (s != c):
      return 1
    return 0
  mid = int(len(s) / 2)
  left = good(s[:mid], chr(ord(c) + 1)) + int(len(s) / 2 - freq(s[mid:], c))
  right = good(s[mid:], chr(ord(c) + 1)) + int(len(s) / 2 - freq(s[:mid], c))

  return min(left, right)


t = int(input())

while(t > 0):
  t -= 1
  n = int(input())
  s = input()
  print(good(s, 'a'))
