# coding: utf-8

alphabet = "abcdefghijklmnopqrstuvwxyz"
t = int(input())
responses = []

def good_string(i, string):
  i = i if i < len(alphabet) else 0
  c = alphabet[i]
  if len(string) == 1:
    return 0 if string == c else 1

  mid = len(string) // 2
  left = string[:mid]
  right = string[mid:]
  left_c_count = right_c_count = 0

  for j in range(mid):
    left_c_count += (1 if c == left[j] else 0)
    right_c_count += (1 if c == right[j] else 0)

  cost_left = good_string(i+1, left) + (len(right) - right_c_count)
  cost_right = good_string(i+1, right) + (len(left) - left_c_count)

  return min(cost_left, cost_right)

for _ in range(t):
  n = int(input())
  s = input()
  responses.append(good_string(0, s))
  
for response in responses:
  print(response)